An example of the recently used shell and awk is provided.

Source: Internet
Author: User
Tags call shell

Mainly shell several common operations: 1 shell and awk combined with 2 shell string operations 3 shell file operations and awk combined 4 file MD5 verification 5 results output 6 passing parameters, etc.

 

 

The following content cannot be completely correct, but is not a copy of the original text.

 

$ Sh test. Sh tablename 20090310

 

Use the preceding statements to call shell. tablename and 20090310 are two parameters.

 

It is also assumed that there is a log file *. log. Generally, the use of awk also analyzes many logs.

 

Assume that log. log has the following text: systemname '2017-02-28 10:00:00 '123 '...

 

SH Content:

 

# Note

Servername = 192.168.10.1

Tablename = $1

Filedate = $2

Interfacefilename = log. Log

 

CD./log

 

 

Logfilename = log _ $ tablename. Log

Echo $ logfilename

 

Interfacename = int

Interfacename =$ {interfacename }_$ {tablename: 1}

Interfacename =$ {interfacename }_$ {filedate} _. Log

Echo interfacename

 

Filesize = $ (LS-L $ logfilename | awk '{print $5 }')

 

Filedate = $ (cat $ logfilename | gawk-F/''{print $2 }')

 

Filemd5 =$ (md5sum $ logfilename | awk '{print $1 }')

 

# Output file

 

Echo "$ servername | interfacename | filesize |..." >$ {interfacefilename}

 

 

 

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.