Find the shell script code for the specified suffix file in the specified directory _linux shell

Source: Internet
Author: User
Copy Code code as follows:

#!bin/sh
# Find the file for the specified suffix at the specified location, including subdirectories
Usage
# FINDF $ $
# The first parameter is a suffix
# Find the file for the specified suffix and print it out
# link:www.jb51.net
# DATE:2013/2/26

F ()
{
list= ' Find $2|grep '/.$1/> '
For I in $list
Todo
Echo $i
Done
}

# Print Usage
Print ()
{
echo "Usage:"
echo "$/$1/$2"
echo "The first parameter is the specified suffix name, such as ' H '"
echo "The second parameter is the specified directory, and if omitted this argument defaults to the current directory"
Exit-1
}

# Find in current directory
F1 ()
{
F "$" "*"
}

# in the specified directory to find
F2 ()
{
CD $
F "$" "*"
}

If ["$#"-lt "1"]
Then
echo "Given too few parameters, at least one parameter is required."
Print "$"
Fi

If ["$#"-GT "2"]
Then
echo "There are too many parameters given, up to two parameters."
Print "$"
Fi

If ["$#"-eq "1"]
Then
F1 $
Exit 0
Fi

If ["$#"-eq 2]
Then
F2 $ $
Exit 0
Fi
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.