parsed.org

Tips by tag: filter

Convert DOS Files by xinu on Jan 20, 2005 10:55 AM

There are a few different ways to convert a DOS file to Unix format, but the most available is probably this:

$ col -bx < dosfile > unixfile
colcommandsconvertdosfilterline-endingsnewlineshellunix
Convert Man to HTML by xinu on Jan 12, 2005 11:00 AM

Convert a man page to HTML for easy viewing online:

$ gunzip < /usr/local/man/man8/lsof.8.gz | nroff -man | man2html -title "lsof" > otmp/lsof.html
commandsconvertfiltergunziphtmlman2htmlmanpagenroffonlineshell
Lowercase Conversion by xinu on Jan 12, 2005 11:02 AM

If you find yourself needing to drop the case on the entire contents of a file, you can try this:

$ dd if=original of=filtered conv=lcase

-or-

$ tr '[A-Z]' '[a-z]' < original > filtered
charactersconversionddfilterlowercaseshelltr

You can use tr to remove non-printable characters from a data stream:

$ tr -cd '\11\12\40-\176' < $INPUT_FILE > $OUTPUT_FILE

(This tip taken from http://www.devdaily.com/unix/edu/un010011/.)

charactersconvertfilternon-printableshelltr
Resizing Images by xinu on Nov 03, 2005 08:00 AM

If you find yourself on a machine without the semi-ubiquitous ImageMagick packages, you might at least have pnmscale. Starting with a PNG file, you can do the following to resize it to 450 pixels wide:

$ pngtopnm < ./firefox-upgrade.png | pnmscale -x 450 | cjpeg -smoo 100 -qual 100 > firefox-upgrade.jpg
cjpegcommandsconvertfilterimageimagemagickpngpngtopnmpnmscaleresizescaleshell
Showing Duplicated Lines in a File by cygnus on Feb 15, 2005 04:09 PM

You can use this command to show duplicate lines in a file:

$ uniq -d MYFILE
commandsduplicatesfiltershellsortuniq
RSS