Shell programming for file in $*; What does it mean.

Source: Internet
Author: User

$* is a collection of all incoming parameters for the function (script) where this line command is located
Similar to [email protected] without quotes, no difference
The difference is when the "" is amplified.
"$*" is treated as a string
"[Email protected]" is treated as n string (number of n= parameters)

For is a loop statement
This means that when file takes the value of each parameter, the loop body after do does
The complete statement is
For file in $*;d o
#some_command
Echo $file
Done
Above this is the loop to print each parameter.

#!/bin/sh
Filename= ' Find. /-name "*.h" '
For Atmpfile in ${filename}
Do
Dos2unix ${atmpfile}
chmod 755 ${atmpfile}
Done

Filename= ' Find. /-name "*.cpp" '
For Atmpfile in ${filename}
Do
Dos2unix ${atmpfile}
chmod 755 ${atmpfile}
Done


$FileName is the reference variable filename, you can also define the variable filename=/usr/local that defines the variable as the path name.

Shell programming for file in $*; What does it mean.

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.