Examples are as follows:The third command is to replace all "Arm-none-linux-gnueabi" in the code in the current directory with "Arm-linux"Sed-i ' s/arm-none-linux-gnueabi-g++/arm-linux-g++\-o2\-i\$\ (inc\) \-i\$\ (incsys\) \-static/g ' grep arm-none-linux-gnueabi-g++. -rl ' sed-i ' s/arm-none-linux-gnueabi-gcc/arm-linux-gcc\-static/g '
Sed Awk daily case 3 1. Delete only 2nd rows $ sed '2 d' employee.txt 2. Delete 1st ~ 4 rows $ sed '1, 4 d' employee.txt 3. Delete 2nd ~ The last line $ sed '2, $ d' employee.txt 4. deletes a row $ sed '1 ~ from the first line ~
Recently learned linux commands grep, awk, cut, uniq, wc. The actual application example shows the number of players who use commands every day: www.2cto.com gzip-c-d nohup. out. 'date + % Y % m % d '*. gz | grep/web/api/logic/logicDispatcher | awk '{FS = ""; print $2 ;}' | awk
Sed and awk overlap, but 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. Put the
Sed Awk Example 2 per dayThe p command can be used to output the current pattern space ). 1. Output $ sed 'P' employee.txt 101, John Doe, CEO101, John Doe, CEO102, CEO102, Jason Smith, IT Manager102, Jason Smith, IT Manager103, AJ Reddy, Sysadmin103, AJ Reddy, Sysadmin104, Anand Ram, comment 104, Anand Ram, comment 105, Jane Miller, Sales Manager105, Jane Miller
For shell, sed, grep, and regular expressions in LINUX, you must learn about the common Linux technology-Linux programming and kernel information. For more information, see the following. For example, for a person working in LINUX, shell, sed, grep, python, and other things are hard to learn. In addition, they are regu
A small chestnut that uses sed and awk to process text, sedawk text Chestnut
I have encountered a problem in my homework for the Linux operating system course over the past two days. I feel very interesting and have a great test of awk proficiency. I have shared this with you.
First, the question is as follows:
RECORD # This is the redundant comment line one # r
I recently started to learn shell + sed + awk.
Linuxsir. orgSee the following comments
ArticleTo make it easy for more people to see it! Shell + sed + awk
The three features are the weakest and not debugged.
ProgramMost operations can be performed only by running other programs. Therefore, more time, memory, and lo
Reprinted from Jrckkyy final edit Zengzhaonong
Using shell variables in sed and awk----------------------------------------------x=mmSed ' s/ab/' $x '/g ' B.COrSed ' s/ab/' "$x" '/g ' B.CSed ' s/' "$val" '//' UrfileThe most recent process of anticipation, using bash scripts, requires the use of shell variables in the script's sed and
OneSed:stream Editor, stream editors;awk (gawk): Text formatting tool, Report BuilderTwo SED stream editor for filtering and transforming textsed [OPTION] ... {Script-only-if-no-other-script} [Input-file] ...Working mechanism: Each time a line of text is read into "pattern space", the processing is done in the mode space, and the processing result is output to the standard output device;Command parameters-R
Took an e-mail address, want to go to the address of the heavy.Open the file a look, several columns. There are comma distinctions and there are spaces to distinguish
9589,860122@qq.com,1,1,2015-04-08 15:31:07.763000000, Xianyang, Shaanxi Province, qq.com,59590,4605708@qq.com,1,1,2015-04-08 15:31:07.763000000, Shenzhen, Guangdong Province, qq.com,59591,3307150@qq.com,1,1,2015-04-08 15:31:07.763000000, Hangzhou city, Zhejiang Province, qq.com,59592,1378747@qq.com,1,1,2015-04-08 15:31:07.76300000
ObjectiveUse Nginx website may encounter abnormal access traffic, be friendship detection, program appeared bug and other sudden situation, then everyone's reaction must be the first time to analyze the log, and then found that the log has more than dozens of GB, but also need to follow the time, error type or key fields to retrieve information will be a kind of clairvoyant, The illusion of a tight chrysanthemum. The method described in this article, whether it is goaccess or
fourth line to AAAAAAAAsed-i '/^selinux/c selinux ' changes all rows starting with SELinux to SELinuxsed-i ' 4d ' to remove line fourthsed-i '/^tom/d ' file delete all lines starting with Tomsed-i '/^$/d ' file to delete empty linessed-i '/^\s$/d ' file delete starts with a blank line \s represents a space or tabsed-i '/^abc/s/tom/jerry/' file first finds the line that starts with ABC change Tom to Jerrysed-i '/^mike/s/^/# ' file notes the Mike linesed-n ' 1p; 3p ' file prints first and third l
sed -i s/"str1"/"str2"/g 'grep "str1"-rl--include="*.[ CH]" ./'Replaces the STR1 string in all. C,. h files in the current directory with the STR2 string.parameter explanation:Sed:-I represents the operation of the file, the ' ' enclosed grep command, which represents the result of the grep command as the action files/
When usingTail-f Test.log | grep "mode" | awk ' {print $} ' commandor tail-f Test.log | When awk '/mode/{print $} ', if there is little data in the test.log that satisfies pattern mode, it will be found that even the new rows in the Test.log that are satisfied with modes do not have any output from the above two commands.The reason is that
same time, First, the simple way to solve my needs.The launcher is simple, and as a service, it needs to run in the background, assuming your executable name is called program.So you need to start:Nohup program [args] To close it requires:#PROGRAM是进程名PID = ' pidof program ' if [!-Z ' $PID ']; Then kill-15 $PID fiHowever, for Java or Python programs, the process is Java or Python, there is no degree of differentiation, so you can not use the "pidof" command, you can only use "ps-ef" comm
-wmp_4-s_4195172997.png "title=" Qq20170401111735.png "alt=" Wkiom1jfg-odmdk4aaaficfz25u286.png-wh_50 "/>Cat Data.txt | Grep-v ' ^$ ' | Sed ' s/^/id/g '---the line of non-whitespace lines in each row of the outfit add id,^ symbol to start with650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/8F/74/wKioL1jfHCuwRhB_AAAcgQvF0vQ789.png "title=" Qq20170401111827.png "width=" 720 "height=" "border=" 0 "
The program becomes a zombie process and requires a process number to force termination, so you need to get the PID of the process first PS | grep Test | awk ' nr==1{print $ {} ' Gets the ID of the test process, in accordance with the format of the Linux output, my device is the first line of the first column of the first parameter is the PID of testIt is not possible to pass PID to KILL-9 through a pipe. S
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.