以下操作對應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