WezM.net The weblog of Wesley Moore

24Apr/080

Expand glob in variable within shell script

I had the need today to read in a list of patterns from a file, expand them and then operate upon each file all from within a shell script. Apparently there is a shell built-in for csh, but I didn't want to learn csh at that point. The eventual solution was to run an extra shell with the -c argument.

Example:

#!/bin/bash
FILES=`cat patterns.txt`
for pattern in $FILES; do
    bash -c "ls -l ${pattern}"
done

Related Posts

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


Trackbacks are disabled.

Recent Comments

Categories

Links

Archives

Tags

adaptive atom awk bash benchmark books cake consolas core-audio debian decoder delivery expand feed font fonts git glob gripe installer iPhone ipod Linux mad melbourne microsoft mp3 mpg123 music package pocket-reference rss ruby script sed shell smoothing snow-leopard textmate title tux UNIX uri-scheme variable virtualbox

Meta

Contact