Home arrow Journal arrow Asigning values from a file to variables in a script
Asigning values from a file to variables in a script PDF
Tuesday, 21 June 2011
If we want to read from a file and transform every line of the file into a value that we want to asign to a variable we can use cat and xargs:

  cat ip_list.txt | xargs echo

Asuming our list is:
10.0.0.1
10.0.0.2
10.0.0.3
10.0.0.4

Our output will be:

10.0.0.1 10.0.0.2 10.0.0.3 10.0.0.4

Every line from the file will be passed as value to echo.

 
< Prev   Next >

Other BSD Systems

OpenBSD

Misc

Solaris

Polls

Best BSD firewall?