1
0
Fork 0
forked from wezm/wezm.net
wezm.net/content/technical/2008/04/expand-glob-in-variable-within-shell-script.html

9 lines
508 B
HTML
Raw Permalink Normal View History

2010-03-11 20:30:27 +00:00
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 <a href="http://docs.sun.com/app/docs/doc/816-0210/6m6nb7mas?a=view">shell built-in for csh</a>, 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