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
UNIX Shell 編程(1)Unix只能識別3種基本的檔案類型:普通檔案、目錄檔案和特殊檔案。普通檔案:any file on the system that contains data, test, program instructions, or just about anything else.統計檔案中的單詞數:wc命令如:[root@localhost test]# wc Makefile 22 84 600
/********************************************************************* * Author : Samson * Date : 08/17/2012 * Test platform: * GNU Linux version 2.6.29.4 * GNU bash, version 4.0.16(1)-release (i386-redhat-linux-gnu) *
/********************************************************************* * Author : Samson * Date : 08/18/2012 * Test platform: * GNU Linux version 2.6.29.4 * GNU bash, version 4.0.16(1)-release (i386-redhat-linux-gnu) *
example about linux shell #!/bin/bashecho "Hello world!"echo "Hello $LOGNAME,It's nice talking to you"echo "U present working on a machine is `uname -n`"echo "U present working directory is $(pwd)"echo "Bye for now $LOGNAME.The time is $(date +%T)"#=
1. if 語句"if"運算式如果條件為真,則執行then後的部分:Toggle line numbers 1 if ....; then 2 .... 3 elif ....; then 4 .... 5 else 6 .... 7 fi大多數情況下,可以使用測試命令來對條件進行測試,比如可以比較字串、判斷檔案是否存在及是否可讀等等……通常用" [ ]