Shell script

Jason Clinton me at jasonclinton.com
Tue Nov 11 23:51:41 CST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

brad wrote:

| I have a tab delimited list of usernames and passwords that I need to
| run a set of system commands on.  I was thinking maybe I could build a
| for loop and assign the first entry on the line as $x and the second
| entry on the line as $y.  Is this possible?  Or am I going to have to
| use sed or awk?

You can enter this at the command line if the Ruby interpreter is installed:

ruby -e "File.open("sourcefile").each_line { |line| system("command #{$1} #{$2}") if 
/(.*)t(.*)/=~line }"

Replace 'sourcefile' with your file 'command' with the command and flags you
want to run. #{$1} and #{$2} are the $x and $y, respectively.

This is my first one liner, BTW. :)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (MingW32)
Comment: Understand the importance of encryption:

iD8DBQE/sWf7tSqjk42zvwkRAhpyAKDJqW64TqEIT5tBCLQouAxQsbh48wCg3mft
6kGT2cIyX1763RWrzOYNflA=
=7oM8
-----END PGP SIGNATURE-----




More information about the Kclug mailing list