Third-party practical shell tool set for unix linux

Source: Internet
Author: User
Tags pkill

 

The third party is ours.

 

1. Path

The environment variable $ path does not wrap the line, and it looks very difficult. Path outputs the $ PATH Branch

Echo-e $ {path //:/'/N '}

2. classpath

Similar to path

Echo-e $ {classpath //:/'/N '}

3. rmall

Recursively delete all files and subdirectories in a directory that meet the conditions

For file in $ (find "$ {1:-not. exist}"-name "$ {2:-not. exist}"); do

Rm-RF $ File

Done

4. pkill

Kill processes by name. in Linux, pkill is provided. When Aix or the like is not provided, the following scripts depend on the PS output format. different platforms need to be fine-tuned.

AIX: for PID in $ (PS Xu | grep "$ {1:-Arg. not. exist} "| cut-F3-D'' | tr ''"/N "); do

Kill-9 $ PID

Done

Red-hat: For proc in $ (PS | grep "$ {1:-notexit}" | cut-F1-d'); do

Kill-9 $ proc

Done

5. linkto

Create Symbolic Links in batches. Sometimes you need to copy one or two of multiple subdirectories of a directory, and create symbolic links for all other subdirectories.

SRC =$ {1:-not. exist}

For file in $ (ls $ SRC); do

Ln-S $ src/$ File

Done

6. findinfiles

Search for a file containing a specific string. Maybe find itself or grep itself can do it. There are too many parameters and it will not be used.

For file in $ (find $1-name "$2"); do
If grep-n "$3" $ file; then
Echo 'found in' $ File
Fi
Done

 

Download sky shell utility: http://cosoft.org.cn/project/showfiles.php? Group_id = 5717

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.