bash - Shell output to text file -


so, have following shell:

#!/bin/bash (( = 1; <= 6; i++ ))      printf in_port=$i,actions=     (( j = 1 ; j <= 6; j++ ))             if [ $i != $j ];                    printf output:$j,         fi     done     printf "\n" done 

which, produces 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 go appending each line of output txt file, line-by-line?

option 1 inside script:

#!/bin/bash (( = 1; <= 6; i++ ))      printf in_port=$i,actions=     (( j = 1 ; j <= 6; j++ ))             if [ $i != $j ];                    printf output:$j,         fi     done     printf "\n" done >> output_file 

option 2 inside script:

#!/bin/bash  exec >> output_file  (( = 1; <= 6; i++ ))      printf in_port=$i,actions=     (( j = 1 ; j <= 6; j++ ))             if [ $i != $j ];                    printf output:$j,         fi     done     printf "\n" done 

option 3 in run command:

./hostsscript.sh >> output_file  

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -