Pipes: Everyday Plumbing with Shell Script

A pipe redirects output from one program or file to the input another program or file. This makes scripting Unix commands possible and incredibly powerful. But like anything powerful, it takes time to develop the skill to get there. It is so useful, it is sometimes hard to express to people only used to looking at their files as “folder icons” what you’re doing. All you can really say is, “programming.” Thus, one can learn a very useful skill on a recovered computer without much capability or Internet availability.

Your task: go read up on shell scripting.

cat remove.names \
| while read F ; do
   fgrep -q "$F" keep.names \
   || (fgrep ",$F" remove.txt | head -1) \
   >> take_back.txt ;
done

Then come back and tell me what I’m doing here :-)

Modern Picture Management?

I like to run a thumbnailer across most of my photos so I have little copies to send around, and I mod them so that they look distinctly different from the full resolution source files. I like to use gwenview to flip and rotate them. Gwenview can export to FB and email so that makes things easier.

I copied a bunch of these thumbs to a project folder. However, I still need to use scripting to sets of pictures from different directories, because they match by name. Buckle up:

ls \
| grep small-imgp \
| perl -pe 's/small-(imgp[0-9]+\.jpg)$/$1/' \
| while read F 
do 
   find /home/jreynolds/9/2012/ -iname "$F" -exec cp {} ~/For-Mary \; 
done

Wow, now I can really get to work.