1. "current shell"Commands enclosed in {} are executed in the current shell. There must be whitespace after the opening {, or else you get a syntax error. One more restriction: commands within the {}'s must be terminated with a semicolon when given
經常需要在Java中調用其它的指令碼(shell,cmd), 以前都用:Runtime r = Runtime.getSystemRuntime();r.exec("whatever you want to run"); 但是有時侯其運行結果是不可預期的,帶來很多麻煩。從java 5.0以後,引入了ProcessBuilder to create operating system processes:String cmd = "cd ../.. ; ls -l"; // this is the
此片文章總結我常用的一些shell指令或一些簡短的指令1. 查看某個工具編譯出來的時間;ll $(which appname)2. 常用for迴圈for i in 1 2 3 4 5; do echo "$i"; done;for((i=140;i<200;i++)); do git tag -d v1.3.$i;done;3. 常用讀取檔案cat filename | while read linedo echo $linedone4. "$@" 的神奇之處for i in "$@
mycommand >mylog.txt 2>&1 應該是最經典的用法了。命令的結果可以通過“%>”的形式來定向輸出,%表示檔案描述符:1為標準輸出stdout、2為標準錯誤stderr。系統預設%值是1,也就是“1>”,而1>可以簡寫為>,也就是預設為>。stdout的預設目標是終端,stderr的預設目標為也是終端。我們在批處理中執行: echo text >result.txt ,我們就可以在螢幕上會看到 echo text
本文由larrylgq編寫,轉載請註明出處:http://blog.csdn.net/larrylgq/article/details/7395261作者:呂桂強郵箱:larry.lv.word@gmail.com變數:aaa="lv";不要空格echo $aaa->lvecho ${aaa}txt->lvtxtecho $aaa.txt->lv.txt求值:a=1b=21:let: let c=a+b echo $c 32:$[]: d=$[ a + b ]
Shell版本sh:Bourne Shell,最初UNIX的shell。csh:C shell。ksh:Korn shell。bash:Bourne Again Shell。 Linux預設shell。tcsh:C shell的擴充。pdksh:ksh不免費,這個免費。echo -n "Date and time is:" -n不換行。echo "your name is: `whoami` "