#!/bin/bash # parse v0.1 # # I needed this to perform some funky operations on the slackware # package list, and though it's simple, quite limited, and fairly dumb, # parse has proven itself useful much more than once, especially for # creating ad-hoc uninstaller scripts from filtered finder results! # # have fun! # # (c) 2005 cor @ corz.org ;o) if [ "$1" != '' ]; then for lines in $(cut -d# -f1 $1) do $2 $lines done else clear echo echo " parse: do something to each line of a text file.." echo echo " usage: parse " echo echo " ..will run through and do to each line of text in the file." echo " comments (lines beginning with \"#\") are ignored. note: if is made" echo " up of multiple commands, enclose them in quotes.." echo echo " parse pkglist \"slackpkg search\"" echo echo " your results come back on standard output, do what you like with that.." echo echo " parse pkglist \"slackpkg search\" >> output.log" echo echo " here's something you can try at home, check on your LAN.." echo echo " parse /etc/hosts \"ping -c 1\" >> lan-ping.log" echo exit 0 fi