commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
If you are in ex mode in vim i.e. you've pressed ':'. You can edit the current command by pressing <ctrl-f>
If you've ever wanted to change a text files contents without having to create an intermediate file. This is it. Ex is a part of vim. The command as given will delete ALL lines containing "delete this line" from the file.
More Examples: print '%s/'this is a line'/'that is not the same line'/g\nwq' | ex file.txt will substitute the first string with the second string. print '3a\n'Inserted Line'\n.\n\nwq' | ex file.txt will insert the given line after line 3.
CAVEAT, Some distro's like the print command, others like echo with this command. Also note there are NO error messages on failure, at least that I've ever seen. Ex can also be quite fussy as to how it takes strings, parameters, etc... I use at&t's ksh syntax may very with other shells.
converts encoding of a file to unix utf-8
useful for data files that contain what would be usable ascii text but are encoded as mpeg or some other encoding that prevents you from doing common manipulations like 'sed'