標籤:
1. cat cat is used to read, display, or concatenate the contents of a file
cat file.txt //show the content of file.txt 顯示file.txt中的內容cat file.txt file1.txt.... //show the content of file.txt file1.txt ..... 顯示多個檔案file.txt file1.txt...的內容cat file.txt | tr -s ‘\n‘ //show the content of file.txt. It will squeeze adjacent ‘\n‘ characters into a single ‘\n‘ 顯示file.txt的內容,並且將連續的空行換成一個
cat -T file.txt //show the content of file.txt and highlight tab characters as ^I 顯示file.txt中的內容,並且將TAB自付顯示為^I
cat -n file.txt //show each line with a line number prefixed 顯示檔案中的內容,每一行帶有行號
2. find list all the files and folders from the current directory to the descending child directories
find base_path //list all files and subfiles in base_path find /root/deploy_ws/ -name "testlist.*" //list all files with filename starting with testlist in /root/deploy_wsfind /root/deploy_ws/ -iname "testlist.*" //list all files with filename starting with testlist in /root/deploy_ws, the more important is to ignore casefind /root/deploy_ws \( -name "testlist.*" -or -name "*.plugin" \) -print //list all files with filename starting with testlist or ending with pluginfind /root/deploy_ws \( -name "testlist.*" -and -name "*.plugin" \) //list all files with filename starting with testlist and ending with pluginfind /root/deploy_ws -path "*BAT*" -print //list all files in /root/deploy_ws and the path for the files should match BAT*find . -regex ".*\(\.txt\|\.sh\)$" //list all files with filename ending with txt or sh in current dir.find . ! -name "*.txt" -print //list files the name does not end with .txt
find . -type d -print //List only directories including descendants
find . -type f -print //List only regular files
find . -type l -print //List only symbolic links
find /usr/lib/firefox/plugins -type l -print //list symbolic links in /usr/lib/firefox/plugins
Some useful shell command