This question already has answers here:
How do I get the result of a command in a variable in windows? [duplicate]
(13 answers)
Closed 3 years ago.
I want to use result of one command in the next command line. Is there any way to do it? preferably in one line. For e.g.
1st: where svn;
2nd: explorer {{result_from_first_cmd}}.
I tried explorer where svn. Evidently didn't work.
Use a FOR loop. Yeah, it's crazy. It's Windows.
FOR /F "delims=" %%A IN ('where svn') DO (explorer "%%~A")
Which operating system are you using? Usually you can pipe outputs of one comman line tool to the next one using the | (pipe) operator.
Related
This question already has answers here:
Are shell scripts sensitive to encoding and line endings?
(14 answers)
Closed 1 year ago.
I am trying to paste two files together
file ip.txt
10.32.216.15
10.23.134.8
10.33.2.37
10.33.84.20
10.33.17.38
file obj.txt
obj-10.32.216.15
obj-10.23.134.8
obj-10.33.2.37
obj-10.33.84.20
obj-10.33.17.38
and I use the command like this:
paste ip.txt obj.txt
However I get this truncated output:
10.32.21obj-10.32.216.15
10.23.13obj-10.23.134.8
10.33.2.obj-10.33.2.37
10.33.84obj-10.33.84.20
10.33.17obj-10.33.17.38
The two files are created by grep command in my script earlier. This behavior is also present when I used variables with the command.
Also when I try to specify a delimiter only the second file gets pasted.
Does anyone know what might be the issue? Thanks
The issue was with line endings, for some reason Windows were set up but Unix were needed.
This question already has answers here:
How to create batch file in Windows using "start" with a path and command with spaces
(7 answers)
Closed 2 years ago.
So normally I have several *.bat files to automate some things in my computer.
But I'm kinda stuck in this call...
cd "C:\Users\user\AppData\Local\Programs\program2Execute"
start program has spaces.exe
I don't get the app executed, instead I get a cmd window with the cd command result, nothing else. I tried to quote "program has spaces.exe" but it doesn't get executed I get the window duplicated instead.
Apologize if this is kinda dumb to ask, but I have spent quite time looking for the answer.
Thanks in advance.
If you use the start command:
start "" "a program with spaces.exe"
start will use the first double quoted string as the title and the 2nd as the command.
Or don't use start:
"a program with spaces.exe"
This question already has answers here:
What does an echo followed immediately by a slash do in a Windows CMD file?
(1 answer)
Batch file new line problems
(2 answers)
Closed 4 years ago.
I was reading this question where I saw not one but two separate answers where the code provided used a form of echo( with no closing parenthesis.
What does this form of the command do?
I am familiar with echo. to perform an echo of an empty line but I've not seen this other form before.
This question already has answers here:
Using getopts to process long and short command line options
(32 answers)
Closed 8 years ago.
I want to write a bash shell script, it can accept parameters, and the parameter has prompt, example,
./test.sh --version=1.0
value 1.0 is the real parameter for my shell, and --version= is the prompt
is there any easy way to do it like this?
You should have have a look at man(1) getopt.
Depending what you mean by "easy" - using getopts should work. A bit of typing, but... Here are some examples to get you started:
http://rsalveti.wordpress.com/2007/04/03/bash-parsing-arguments-with-getopts/
How do I parse command line arguments in Bash?
http://spin.atomicobject.com/2011/03/30/parsing-arguments-in-bash-with-getopts/
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How do I escape ampersands in batch files?
I am attempting the following, in Windows:
$ start http://code.google.com/p/mulder/downloads/detail?name=MPUI.2011-06-09.Full-Package.exe&can=2&q=MPlayer&sort=-uploaded
Unfortunately, it seems that no amount of quoting or escaping actually pulls up the full URL in a browser, only partial (up through can=2) or what not. How can I do it?
You can use ^ to escape & in teh command line like this:
$ start http://code.google.com/p/mulder/downloads/detail?name=MPUI.2011-06-09.Full-Package.exe^&can=26^&q=MPlayer^&sort=-uploaded
Try this
start "test" "C:\Program Files (x86)\Internet Explorer\iexplore.exe" "http://code.google.com/p/mulder/downloads/detail?name=MPUI.2011-06-09.Full-Package.exe&can=2&q=MPlayer&sort=-uploaded"
It worked for me in Windows 7. (all on one line).
I hope this helps.