Shell Script

One line scripts

追蹤 log file

tail -f -n1 log.txt | grep "^\[INF\]"

遞迴列出檔名(含路徑)

find -name *.txt

搜尋現有目錄及子目錄下所有 txt 檔,看是否含有 png 字串

grep png `find -name '*.txt'`
# Option "--include" is available at GNU grep 2.5.3
grep -r --include=*.txt png

matches lines containing the word "cat" or the word "dog"

grep "cat\|dog" file

Reference

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License