shell scripting gurus?
Sandy Harris
sandyinchina at gmail.com
Thu Jun 5 15:16:51 UTC 2008
On Thu, Jun 5, 2008 at 11:07 PM, Bart Silverstrim
<bsilver at chrononomicon.com> wrote:
> If I have a file of IP addresses, one per line, is there an easy way to
> have a shell script read each line and perform an operation that plugs
> that IP into another command?
If the file is not too long, it is easy. You just use backquotes, the
` character,
around a cat command. Something like:
for i in `cat list_file`
do
script_file $i
done
The backquoted command is run and its output substituted into
the command line. So if list_file has a, b, c and on four lines,
you get "for in in a b c d"
This fails if the list is long enough that it won't fit in the
command parser's buffer. There's a way around that,
but I don't recall it right now.
--
Sandy Harris,
Nanjing, China
More information about the ubuntu-users
mailing list