I'm a noob scripter, and I'm trying to create a script for automatic device creation.I'm pretty far already, but I am stuck at one point. The source file looks like this:dev1 size 1024dev2 size 1024dev3 size 1024dev4 size 512dev5 size 512In the script the source file is the variable $INVFILE. Then I issue the commandcat $INVFILE | awk '{print $3}' | sort | uniq -cWhich gives the following output:   3 1024   2 512I want to use this output in the following command, so that it uses the different sizes, and their counts (for this example I'm using the first line only, but in the script I want to use both lines in a sort of for i in function).create dev count=3 size=1024MBHow can I do this in the script? And is there an easier way instead of the for i in function?
Help in separating columns from command into a new command
shell script;scripting
awk '{print $3}' $INVFILE | sort | uniq -c | \while read a b ; do \    create dev count=$a size=${b}MB ; \donefor only uses one list item per loop cycle, while read x_1 x_2 x_3... uses however many x_ns there are, (but never more items than happen to be in one line of the input file).Note, if any of the input had more than two columns, change 'read a b' above to 'read a b c' -- the $c wouldn't be used in the loop, but it prevents read from assigning the rest of the line to $b.The first line of pipes can be swapped out with datamash, with $a & $b swapped in the loop:datamash -W -s -g3 count 3 < $INVFILE | \while read a b ; do \    create dev count=$b size=${a}MB ; \done