[lug] Odd Shell Script Queries
anselmi at anselmi.us
Tue Jan 18 16:44:42 MST 2005
Chip Atkinson wrote:
> On Tue, 18 Jan 2005, Matt Thompson wrote:
>>>echo "ibr-.355.3graph.notitle.pdf"| tr '\.' '_'
> I'd pipe it through sed myself:
> echo ibr-.355.3graph.notitle.pdf | sed -e 's/\./_/g' -e 's/_pdf$/.pdf/'
sed isn't bad if you don't know the extension:
sed -e 's/\./_/g' -e 's/_\([a-z][a-z][a-z]\)$/.\1/'
but if your regex gets much more involved you'll want Perl. But if you
know, basename can strip the extension for you:
for file in *.pdf ; do
name=$(basename $file .pdf)
name=$(echo $name | tr '\.' '_')
mv $file $name.pdf
> If you can create the same document in color and black and white, you
> could diff the two and look for kewords. Then you could use grep to
> search for them and if found print to color.
Or just print the whole thing in b/w and print the few pages in color.
Your print command ought to have a way to select pages to print.
More information about the LUG