Is this the best way to split up a colon separated bash command line argument?
#!/bin/bash
hostlist=`echo $1| awk '{split($0,Ip,":")} END{for (var in Ip) print Ip[var];}'`
for host in $hostlist
do
....
done
|
Is this the best way to split up a colon separated bash command line argument?
|
|||||
|
|
Another way would be to use IFS, the shell's built-in method to split strings into fields.
|
||||
|
|
|
I think the simplest solution is just to use bash builtins:
Another way (still simpler than your awk solution) is to use cut though this probably depends on GNU cut.
|
||||
|