Some usage of Sed \ Awk sed non-interactive stream editor www.2cto. comsed & amp; #39; 1, 4d & amp; #39; myfile # delete 1 to 4 rows of data sed & amp; #39;/La/d & amp; #39; myfile # delete a data row containing La // search for sed & amp; #39;/[0-9] \ {3 \}/d & amp; #39 ;..
Sed \ Awk usage sed non-interactive stream editor www.2cto.com sed '1, 4d 'myfile # delete 1 to 4 rows of data sed '/La/d' myfile # delete data rows containing La // search for sed'/[0-9] \ {3 \}/d' # myfile deletes a row containing three digits, the rest show sed '/^ $/d' myfile # Delete the blank row of myfile, starting with ^ Table, $ sed at the end of the table'/La /! D 'myfile # delete sed-n 'La/p' myfie # display the data rows containing La, -n: only display the sed-n's/La/Oo/gp 'myfile # Replace All La with Oo, and display sed-n's/La // P' myfile # delete sed's/^ From the first line of La... // 'myfile # delete sed's /... $ // 'myfile # delete sed-n's/\ (La \)/\ 1Oo/p' myfile from the end of each line # save the found La, use \ 1 to retrieve and use sed-n'/AAA/s/234/567/p' myfile # to find the row containing AAA, replace 234 with 567 sed-n'/AAA/,/DDD/s/B/567/p' myfile # replace AAA with the lines containing DDD, change B to 567 s. Ed-n '2, 4S/B/567/p' myfile # from 2nd rows to 4th rows, change B to 567 awk text cutting tool ps auxw | awk '{print $2}' # obtain the system's current pid list awk '/La/'myfile # display La-containing data row awk '{print $1, $2} 'myfile # display the 1st and 2nd fields of each myfile line awk '/La/{print $1, $2} '# display the 1st and 2nd fields that contain the La keyword awk-F:'/^ user1/{print $3, $4} '/etc/passwd # Use option-F, specify: print the uid and gid awk-F of account user1 as the separator: 'In in {OFS = "++"} '/^ user1/{print $1, $2, $3, $4, $5} '/etc/passwd # use: as the separator, ++ as the output field separator, and set 1st of user1 ~ Ifconfig | grep 'inet addr: '| grep Bcast | awk' {print $2} '| awk-F: '{print $2}' # obtain the nic ip address cat/proc/net/dev | awk-F: '/eth.: | ppp.: | wlan. :/{print $1} '# get the network device name cat/proc/meminfo | awk'/MemTotal/{print $2} '# get the memory size
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