115:wc -l:find . -iname "*test*":find /tmp/ -iname "*test*"
I would like to parse the string above.
In my case, a string consists of 4 columns (every command has
: separator) but it can be much longer.
I want to "pull out" all the commands including initial number, starting with
115 and continuing with
wc -l, -iname "*test*",
find /tmp/ -iname "*test*" ... always without
$var should get those values:
var= 115 , var= wc-l , var= find . -iname "*test*" , var= find /tmp/ -iname "*test*"
while read line; do while [[ $var -ne '0' ]]; do var=$( echo $line | cut -d ':' -f$i ) i=$( expr $i + 1 ) echo $var done done <$1
I read lines from file and with second while I cut columns until empty one. Obviously, there is something wrong because echo do not print anything.