mirror of
https://github.com/wezm/wezm.net.git
synced 2024-11-14 03:18:02 +00:00
QA /technical/2008/04/expand-glob-in-variable-within-shell-script/
This commit is contained in:
parent
7a5d2f6736
commit
f0ec1111d3
1 changed files with 6 additions and 5 deletions
|
@ -1,8 +1,9 @@
|
||||||
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.
|
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:
|
Example:
|
||||||
<pre>#!/bin/bash
|
#!/bin/bash
|
||||||
FILES=`cat patterns.txt`
|
FILES=`cat patterns.txt`
|
||||||
for pattern in $FILES; do
|
for pattern in $FILES; do
|
||||||
bash -c "ls -l ${pattern}"
|
bash -c "ls -l ${pattern}"
|
||||||
done</pre>
|
done
|
||||||
|
|
Loading…
Reference in a new issue