Let’s say you’ve got a file with the following lines:

cat file.txt 
leave me alone
leave me alone
comment me out
leave me alone
comment me out also
leave me alone

Comment out the lines that are begging for it:

sed -i '/comment me out/s/^/#/g' file.txt

Voila:

cat file.txt 
leave me alone
leave me alone
#comment me out
leave me alone
#comment me out also
leave me alone

Once again I did something that changed the host key (like rebuild the host). Now I’m trying to SSH to it and get the usual warning from SSH that the key is different. In the past, I’d open up ~/.ssh/known_hosts with VIM, enter “:” and line number SSH referred to, hit “dd” to delete it, then “:wq” to write and quit VIM, only to get warned again that the key for the IP address host is known by has also changed and do the whole dance over again.

But tonight is different. Tonight I’m gonna give the keyboard a break.

This will delete line 93 from known_hosts:

sed -i 93d ~/.ssh/known_hosts

The shell one line script below will:

1. Find all files below current dir
2. Rename the file with download Source and date range as part of the new file name
3. Renamed file will stay at current location (e.g. file “./path/to/dir/crappyname” becomes “./path/to/dir/DC.Circuit-2006.06.02-2006.07.01.txt”)

Read the rest of this entry…

Display all lines from file except lines between two lines matching a pattern:

1
sed '/10\/02\/1992/,/01\/02\/2001/d' input.txt

Display lines between two lines matching a pattern:

1
sed -n '/10\/02\/1992/,/01\/02\/2001/p' input.txt

Read the rest of this entry…