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
Recent Comments
- Jussi on Install Microsoft’s Consolas Font on Mac OS X
- Caitlin on iPhone 3G One Week In
- leo on Install Microsoft’s Consolas Font on Mac OS X
- Michael Wang on Exclude Directories From TextMate Side Bar for Faster Find in Project
- David Merrill on Install Microsoft’s Consolas Font on Mac OS X
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