What are the advanced ways to use bash
Xiaobian to share with you what bash advanced use methods, I believe most people still do not know how, so share this article for your reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!
One of the distributions of linux-Redhat/CentOS-the default shell installed on the system is called bash, or Bourne Again Shell, which is an enhanced version of sh (Bourne Shell). Bourn Shell is one of the earliest shell, the founder is called Steven Bourne, in memory of him so called Bourn Shell, check called sh.
1. List the last ten directories in chronological order ls /mnt/daily/Concord/main-sort-t| awk /_[0-9]+-[0-9]/'{print $NF}' |tail -10/mnt/daily/LotusLive directory content is as follows: SC10.0_Docs :dirSC10.0_DocsProxy :dirSC20.0_Docs :dirSC20.0_DocsProxy :dirSC30.0_Docs :dirSC30.0_DocsProxy :dirSC30.16_Docs :dirSC30.16_Viewer :dirtsm_backup :file2. recursively delete empty directory # $1 must be an absolute path crurl=$1func_hdir(){echo $crurlcd $crlfor aitem in `ls -l| grep "^d" | awk '{print $9}'`; docrurl=$crurl/$aitemfunc_hdir $aitemdonedirc=`ls $crurl`if [ "$dirc" = "" ]thenecho $crurlrm -rf $crurlficrurl=${crurl%/*}}func_hdir3. sed delete specific lines sed -e '/^[ ]*$/d' osgi_file > target_file //delete empty lines sed -d '/concord/d' osgi_file>target_file//lines containing concord 4. Output the latest N directories find /mnt/daily/Concord/main -mindepth 1 -maxdepth 1 -type d -printf "%T@%Tx %p"| sort -n -r | head -N5. Find /mnt/daily/Concord/main-mindepth 2 -maxdepth 1 -type d -mtime -5-mtime The maximum number of directories created in the last 5 days is 8. If it exceeds 8, it will output all 6. sort by specific columns such as applications currently working, sorted by MSG_NODE_%d, can be found with the command. -type f -name envconfs.conf | grep -v "chatroom"| grep "appnodemessagepool"| sort -t '. ' -k4find . -type f -name envconfs.conf|grep "appnodemessagepool"|sort -t '/' -k2./ com.rcloud.appnodemessagepool.MSG_NODE_3/conf/envconfs.conf./ com.rcloud.appnodemessagepool.MSG_NODE_4/conf/envconfs.conf./ com.rcloud.appnodemessagepool.MSG_NODE_5/conf/envconfs.conf The above is "What are the advanced use methods of bash?" All the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!