Shell scripts pass parameters with spaces [excerpt from network]

Source: Internet
Author: User

parameter Handling Description
$# The number of arguments passed to the script
$* Displays all parameters passed to the script in a single string
$$ The current process ID number for the script to run
$! ID number of the last process running in the background
[Email protected] With $ #相同, but use quotation marks and return each parameter in quotation marks.
$- Displays the current options used by the shell, the same as the SET command function.
$? Displays the exit status of the last command. 0 means there is no error, and any other value indicates an error.
MD DUANWF 23742 CDR_CALL_YYYYMMDD/HOME/DUANWF/ASIAINFO/EXPORT/T141015001_20141014.AVL & Fetch first 100000 rows Only

The final "Fetch first 100000 rows only" is the seventh parameter, but only the fetch is obtained when it is recognized.

How do you deal with that?

Before asked someone said can use double quotation marks to bring him, the final result is still the same, unable to get, can only get to

The Fetch

Automatically disconnects before a space.

 Can be processed by the [email protected] command, the $7 will be replaced by Echo ${@:7}, so that the 7th start is automatically recognized, all obtained as the last 7th parameter, the parameter gets changed to:

Shell scripts pass parameters with spaces [excerpt from network]

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.