Showing posts with label Shell. Show all posts
Showing posts with label Shell. Show all posts

Thursday, September 27, 2012

[Linux] Bash tips

bang bang


$ !!
执行上一个命令
$ !x
执行上一个以"x"开头的命令
$ !xyz
执行上一个以"xyz"开头的命令

bang dollar

$ cat ~git/repository/foo.git/hooks/post-receive
$ vi !$
!$会被扩展为上一个命令的最后一个argument
类似的!*会被扩展为上一个命令的所有argument

dollar bang

$ ./exe_something &
$ LAST_PID= $!
$!为上一个命令的PID

dollar question-mark

$ ./exe_something 
$ echo $?
$?为上一个命令的exit状态

Saturday, April 17, 2010

[Linux]cheeting sheet of sh, csh, bash

sh, csh, bash 比较

Statement sh tcsh bash
if-then-else
if [ expression ] 
then
    ...
else
    ...
fi
if (expression) then
    ...
else
    ...
endif
注:then必须和if同一行
if [ expression ]
then
    ...
else 
    ...
fi 
for-loop
for var in (list)
do
    ....
done
foreach var (list)
    ...
end
for var in [list]
do
    ...
done 
Loop in Bash: http://www.cyberciti.biz/faq/bash-for-loop/

Sh: http://www.freeos.com/guides/lsst/
Bash: http://tldp.org/LDP/abs/html/