Some useful shell command

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_ws
find /root/deploy_ws/ -iname "testlist.*" //list all files with filename starting with testlist in /root/deploy_ws, the more important is to ignore case
find /root/deploy_ws \( -name "testlist.*" -or -name "*.plugin" \) -print //list all files with filename starting with testlist or ending with plugin
find /root/deploy_ws \( -name "testlist.*" -and -name "*.plugin" \) //list all files with filename starting with testlist and ending with plugin
find /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

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。