1

With cmd.exe's interpreter this is easy:

echo testline > .\test.txt && c:\windows\system32\notepad.exe .\test.txt

What is the equivelent to this with bash?

For instance, vim doesn't execute when I run the following:

 ./check_nrpe -H 192.168.100.20 -c CheckEventLog -a MaxWarn=1 MaxCrit=1 file='Security' filter=out filter+eventType==auditFailure filter+generated=\<10m filter+eventID==534 filter+message=substr:'mbrown' descriptions > test1.csv && vim test1.csv

Does it have to do with the double redirector?

3
  • 1
    Have you tried doing the same in bash?
    – andol
    Aug 31, 2011 at 19:21
  • 3
    If you replaced notepad.exe with vi or some other editor, and fixed the slashes, then that command should run as written.
    – Zoredache
    Aug 31, 2011 at 19:23
  • yes... corrected original question
    – brandeded
    Aug 31, 2011 at 19:23

2 Answers 2

3

&& works with short circuiting and second command will execute only if first command is correct. You can try using ; to separate two commands if it is ok for second command to execute unconditionally.

3
  • will they execute concurrently or sequentially when using the ; ?
    – brandeded
    Aug 31, 2011 at 19:57
  • the clue was in the answer. Read and understand before asking a question that has already been answered.
    – goo
    Aug 31, 2011 at 21:11
  • 1
    The ; separator will cause the commands to execute sequentially. If you want the second command to start without waiting for the first to finish, try using & instead. Sep 1, 2011 at 4:30
2

Use the && separator. Just as cmd.exe.

sudo apt-get update && sudo apt-get dist-upgrade
2
  • Sorry forgot to ad relative paths :'(
    – brandeded
    Aug 31, 2011 at 19:26
  • Just ran your amend and it worked perfectly - results.csv got written and vim opened it.
    – growse
    Aug 31, 2011 at 19:38

Not the answer you're looking for? Browse other questions tagged .