以下操作对应bash.
1. set -v :在每行脚本命令执行前,先在终端显示出来. sed +v: 关闭.
set -x :类似set -v, 但已经对命令做了解析. sed +x: 关闭.
2. pushd/popd. pushd用于将目录压入一个堆栈, popd用于推出. 符合FILO特性.
[kenny@sea etc]$ pushd /home/
/home /etc
[kenny@sea home]$ popd
/etc
[kenny@sea etc]$
3. 创建一个带时间的文件.
[kenny@sea testcode]$ touch test`date +%Y%m%d` ### see `man date` for more option.
4. cp: preserving time for XXXXXXX: Operation not permitted 错误.
Linux下对不同属主的文件进行拷贝替换,会报权限不足, 解决方法是 对源文件夹和目标文件夹设置属主.
`chown -R new_user:new_group $DIR`
5. for的使用. 范例,从1加到100.
src: http://www.grymoire.com/Unix/Quote.html
http://www.mathworks.com/support/solutions/en/data/1-98H2VH/index.html?product=ML&solution=1-98H2VH
6. 命令行中循环调用.
$for i in `seq 1 100`; do echo $i; dmesg | tail -f; sleep 1; done
7. stdin中Ctrl+D表示EOF输入.
a. $ dircolor -p >default_dircolors
b. 拷贝default_dircolors至 ~/, 例如/root, /home/jobs/目录, 重命名为.dircolors. 修改文件中STICKY_OTHER_WRITABLE和OTHER_WRITABLE的数值:
STICKY_OTHER_WRITABLE 01;34 # dir that is sticky and other-writable (+t,o+w)
OTHER_WRITABLE 01;34 # dir that is other-writable (o+w) and not sticky
Note: ~/.dircolors将被~/.bashrc调用.
Src: http://www.cyberciti.biz/tips/where-is-color-of-ls-command-defined.html