Archive for January, 2010

VIM Control Characters – search and replace

Monday, January 25th, 2010

Control characters require an escape sequence prior to using in a search and replace operation in VIM. In Linux, the escape character is Ctl-v. Windows requires a Ctl-q.

Remove all ^M characters from a file on Linux:


Remove all ESCAPES (\27, ^[) from a file on Windows:


Bash Tip! Renaming files using Bash string operations

Wednesday, January 6th, 2010

To rename all html files in a particular directory to shtml files, use the following loop:

for file in *.html
  mv ${file} ${file%%.html}.shtml

This uses the ${variable%%match} format which strips the longest match from the end of the variable.