So, I have the following shell:
#!/bin/bash
for (( i = 1; i <= 6; i++ ))
do
printf in_port=$i,actions=
for (( j = 1 ; j <= 6; j++ ))
do
if [ $i != $j ]; then
printf output:$j,
fi
done
printf "\n"
done
Which, produces the following output:
home@mininet:~$ ./hostsScript.sh
in_port=1,actions=output:2,output:3,output:4,output:5,output:6,
in_port=2,actions=output:1,output:3,output:4,output:5,output:6,
in_port=3,actions=output:1,output:2,output:4,output:5,output:6,
in_port=4,actions=output:1,output:2,output:3,output:5,output:6,
in_port=5,actions=output:1,output:2,output:3,output:4,output:6,
in_port=6,actions=output:1,output:2,output:3,output:4,output:5,
How would I go about appending each line of this output to a txt file, line-by-line?
command > output_filecommand >> output_filefor the next lines (1 > overwrites the file, >> appends to the file).( command1; command2 ) > output_file.{ command1; command2; } > output_filewould be better yet.for ... do; done > output_file:-)