# 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 " [01;33mparse[00m:[01;32m do something to each line of a text file..[00m" echo echo " [01;33musage:[00m [01;35mparse <file> <command(s)>[00m" echo echo " ..will run through <file> and do <command> to each line of text in the file." echo " comments (lines beginning with \"#\") are ignored. [01;31mnote:[00m if <command> is made" echo " up of multiple commands, enclose them in quotes.." echo echo " [01;35mparse pkglist \"slackpkg search\"[00m" echo echo " your results come back on standard output, do what you like with that.." echo echo " [01;35mparse pkglist \"slackpkg search\" >> output.log[00m" echo echo " here's something you can try at home, check on your LAN.." echo echo " [01;35mparse /etc/hosts \"ping -c 1\" >> lan-ping.log[00m" echo exit 0 fi