Common sed and awk functions

Source: Internet
Author: User
Sed shares the common functions sed and awk. However, we can understand that sed performs operations on text content (text replacement) and awk performs operations on text structure. 1. replace zhc in the filename File with hongchangfirst and put it in filename2. Sed & amp; lsquo; s/zhc/hon... sed shares the common functions sed and awk. However, we can understand that sed performs operations on text content (text replacement) and awk performs operations on text structure. 1. replace zhc in the filename File with hongchangfirst and put it in filename2. Sed's/zhc/hongchangfirst 'filename> filename2 2 sed script is stored in the scriptname file. Sed-f scriptname filename 3 outputs the first and third columns in the filename file to the filename2 file awk '{print $1; print $3} 'filename> filename2 4 the default delimiter is space. you can use-F to change it to a comma as the separator, and change it to a colon-F: awk-F, '{print $2}' filename> filename2 5 awk script is put into the scriptname file awk-f scriptname filename> filename2 sort | uniq 6 lists the 10 longest-used commands history | awk '{a [$2] ++} END {for (I in) {print a [I] "" I} '| sort-rn | head
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.