Stripping out newlines from string

[problem]

Different versions of UNIX handle the stripping of newlines in a string differently. Obviously if you echo a string, the shell automatically expands newlines “n”.

[/problem]

[solution]

sed and tr don’t appear to like performing these substitutions. But with Perl its a steal. 🙂

[/solution]

[example]


% echo 'hello worldnhello worldntest it' | perl -ane 's#\n# #g; print,"";'

hello world hello world test it

[/example]

[reference]

[tags], Unix Coding School[/tags]

[/reference]

Resize image command line – mogrify

[problem]

You want to resize images from the command line.

[/problem]

[solution]

Use image magik mogrify command.


mogrify -resize "percentage" image_na

Also you can view current sizing – like this:


% identify IMG_3864.JPG
IMG_3864.JPG JPEG 563x422 563x422+0+0 DirectClass 8-bit 32.8887kb

[/solution]

[example]


mogrify -resize 20% IMG_3705.JPG

[/example]

[reference]

[tags]mogrify[/tags]

[/reference]