ls /mnt/daily/Concord/main -sort -t | awk /_[0-9]+-[0-9]/'{print $NF}' | tail -10/mnt/daily/LotusLive目錄內容如下: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. 遞歸刪除空目錄
# $1必須是絕對路徑crurl=$1func_hdir(){echo $crurlcd $crurlfor 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刪除特定的行
sed -e '/^[ ]*$/d' osgi_file > target_file //刪除空行sed -d '/concord/d' osgi_file>target_file//包涵concord的行4. 輸出最新的N個目錄
find /mnt/daily/Concord/main -mindepth 1 -maxdepth 1 -type d -printf "%T@%Tx %p" | sort -n -r | head -N5. 輸出最近5天創建的目錄
find /mnt/daily/Concord/main -mindepth1 -maxdepth 1 -type d -mtime -5-mtime 最大數是8,超過8就是輸出全部6. sort by 特定列
如當前工作中的應用,以MSG_NODE_%d排序,可用如下命令find . -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
原文來自:https://yq.aliyun.com/articles/61017?spm=5176.100239.bloglist.92.86B7DB
本文地址:http://www.linuxprobe.com/bash-list.html
http://xxxxxx/Linuxjc/1184688.html TechArticle