New Scripts
1 Determine which desired items do not exist in a given file. 2011.09.23
Two Patterns
1 Get lines containing PAT1 AND PAT2 of a file. 2000.11.16
2 Get lines containing PAT1 OR PAT2 of a file. 2000.11.17
3 Get lines containing PAT1 but no PAT2 of a file. 2000.09.29
4 Insert a separating line after a line beginning with 'abc' and immediately followed by a line beginning with 'xyz'. 2005.07.29
5 Perform operations on lines starting from the fist line containing PAT1 till the last one containing PAT2. 2008.01.24
Consecutive Lines
1 Delete two consecutive lines if the first one contains PAT11, and the second one contains PAT2. 2007.12.31
2 Remove almost identical lines. 2008.01.21
3 For consecutive `almost identical' lines, print only the first one. 2008.11.28
4 Remove consecutive duplicate lines. 2008.02.21
5 Retrieve the first line among consecutive lines of the same key. 2008.08.25
Mail Issues
1 Extract 'Received:' headers from a mailbox. 2004.05.16
2 Add a separator after each header field of a mail. 2009.08.06
3 Extract matched headers of a mail. 2009.12.25
4 Gather information of a mail transaction. 2010.01.26
5 Find qualified letters in a `mailq' output. 2010.12.24
Lines Containing PAT and Adjacent Ones.
1 Get every line containing PAT and the adjacent one preceding it. 2008.02.09
2 Get every line containing PAT, the preceding, and the following ones. 2009.03.31
3 Get lines containing PAT and 3 consecutive lines following each of them. 2000.11.15
4 Get every line which is adjacent to and precedes a line containing PAT. 2001.02.13
5 Get the line following a line containing PAT. 2004.02.17

6 Delete every line containing PAT and the next three lines. 2009.07.30
N-th Line Containing PAT
1 Get the N-th matched line. 2007.08.23
2 Get the N-th matched line.(another version) 2007.09.03
3 Get the N1-th, N2-th, N3-th, ..., matched lines. 2010.04.30
4 Delete the N1-th, N2-th, N3-th, ..., matched lines. 2010.12.27
First Line Containing PAT
1 Get the FIRST line containing PAT 2000.09.29
2 Get lines starting from the FIRST one containing PAT till the end of file. 2000.10.18
3 Delete the FIRST line containing PAT of a file. 2000.09.29
4 Delete up to, but not including, the first line containing PAT. 2001.02.17
Last Line Containing PAT
1 Get the LAST line containing PAT of a file. 2000.10.04
2 Get the lines from the LAST one containing PAT of a file. 2006.06.22
3 Get the lines after the LAST one containing PAT of a file. 2006.06.28
4 Delete the LAST line containing PAT of a file. 2008.08.06
5 Delete the lines from the LAST line containing PAT till the end of file. 2006.07.19
6 Among lines containing PAT, delete all but the last one of them. 2009.07.28
7 Delete the lines till the LAST one containing PAT. 2007.09.05
8 Perform a specific operation on lines starting from the beginning of a file till the LAST line containing PAT. 2007.01.18
9 Among lines with the same key, print the last one. 2009.08.03
Lines containing N occurrences of PAT
1 Get lines containing exactly N occurrences of PAT. 2011.02.01
Append/Join Conditionally
1 If a line does not end with a dot ('.'), join every following line till one ending with a dot. 2001.02.26
2 A case study on joining lines. 2004.09.29
3 Join every three non-blank lines to one line, separate them by '|'s. 2004.02.12
4 Append a line to the previous one if it does not begin with some tag. 2006.09.13
5 Join together all lines except the last one. 2008.08.12
6 Prepend a block to a file if it does not exist. 2009.07.14
Reformat a File
1 Split lines that are longer than 25 characters. 2001.06.22
2 Move lines containing some string to the end of a file. 2002.12.04
3 Fix newlines at wrong positions. 2004.03.04
4 Add a separator line to the end of every 'block'. 2002.10.04
5 Append a message after very 'block'. 2004.09.10
6 If a non-blank line is not followed by a blank line, append a <br> tag to the end of it. 2006.05.22
7 Show complete records only. 2007.06.12
8 Substitute the section specified in File1 for the same section in File2. 2008.08.18
Two-file Issues
1 List records of File2 whose keys are not listed in File1. 2008.08.29
2 Update entries of File2 according to File1. 2009.05.29
3 Edit the second file according the words and replacements specified in the first one. 2010.05.31
Misc
1 Get the longest line of a file. 2000.10.11
2 Retrieve IPs and interface names from the output of /sbin/ifconfig. 2003.02.21
3 Comment out uncommented lines. 2004.02.27
4 Prepend the contents of some file before every matching line of a file. 2005.10.18
5 Print the last line of each group consisting of lines with the same tag. 2003.01.28
6 Replace every instance of 'KEY=....' of a file with the first one. 2004.06.08
7 Print `ODD' if there are odd number of lines containing PAT in the datafile. 2008.06.23
8 Convert a file listing to FTP commands. 2008.12.23
9 Reformat a datafile. 2009.03.04
10 Delete shell-style comment lines and empty ones. 2009.03.26
11 Determine which desired items do not exist in a given file. 2011.09.23
Main Menu