Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the advanced ways to use bash

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report