Knowledge about shell scripts

Source: Internet
Author: User

1. Exec <$ home/CSV/rushid.csv
Read line
Rushid = $ line
Exec is a pipeline command, which is generally not used separately.
Read from the CSV file and assign each line to line
Read is used to accept keyboard input in shell.

Line is a variable that accepts output parameters.

Ii. Cat commands

1) You can combine a sub-chapter file into a complete file.

$ Cat chap1 chap2 chap3> user_guide

User_guide if the original file is not empty, the text will be overwritten

2) You can use the cat command and I/O redirection (>) function to append the content of the second file to the first file cat file2> file1

3) Note: if you use the following command to merge files, the data content of file1 will be cleared, and only the data content of file2 will be copied to file1. Cat file1 file2> file1

3.

Sed-I's/$/& ', $ {rushid}'/G' $ home/CSV/rush_goodsid.csv
Sed is a text replacement command, just like substr_replace in PHP.
Sed-I indicates that if the file is modified without adding-I, the file is only displayed on the screen, and the file itself remains unchanged.
''Double quotation marks are in the format
S indicates search, and s indicates match in sed.
$ Indicates the end of the line ^ indicates the beginning of the line, and PHP also has a exhausting Regular Expression
& ', $ {Rushid}' is the value of the variable $ {rushid} appended to the end of the row.
/G indicates that all the global files are performing this operation.
Without/g, the variable value is added only at the end of the first line.
The final part is the target file.

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.