search for: test_bash

Displaying 3 results from an estimated 3 matches for "test_bash".

2020 Jul 23
4
Off Topic bash question
Thanks, when I change it do the following I get a syntax error #!/bin/bash # while read LINE do echo $LINE done < cat list.txt ./test_bash.sh ./test_bash.sh: line 6: syntax error near unexpected token `list.txt' ./test_bash.sh: line 6: ` done < cat list.txt'
2020 Jul 23
5
Off Topic bash question
...t -f 1 -d ','` IP=` echo $LINE | cut -f 2 -d ','` names[index]="$NODENAME" ip[index]="$IP" index=`expr index+1` total=`expr total+1` done <<< $(cat list.txt) simple file: more list.txt name1,ip1 name2,ip2 name3,ip3 output when running: sh -x ./test_bash.sh + index=0 + total=0 + names=() + ip=() ++ cat list.txt + read -r LINE ++ echo name1,ip1 name2,ip2 name3,ip3 ++ cut -f 1 -d , + NODENAME=name1 ++ echo name1,ip1 name2,ip2 name3,ip3 ++ cut -f 2 -d , + IP='ip1 name2' + names[index]=name1 + ip[index]='ip1 name2' ++ expr index+1 + ind...
2020 Jul 23
0
Off Topic bash question
...;<<" operator does all manner of expansion of the input and supplies it as a single line. That not what you want. Just redirect stdin from the file instead. > simple file: > more list.txt > name1,ip1 > name2,ip2 > name3,ip3 > > output when running: > sh -x ./test_bash.sh > + index=0 > + total=0 > + names=() > + ip=() > ++ cat list.txt > + read -r LINE > ++ echo name1,ip1 name2,ip2 name3,ip3 This is happening because of the <<< operator. > ++ cut -f 1 -d , > + NODENAME=name1 > ++ echo name1,ip1 name2,ip2 name3,ip3 > ++...