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 :-)

Advertisements