I have a space delimited data out from a program in horizontal:
0 2 32 323 443 ...
I created a shell script to convert horizontal listed file to vertical to sort it out :
filename=/tmp/vList
colcount=$(wc -w < "$1")
counter=1
sortResult=0
while [ "$counter" -le "$colcount" ]
do
cat "$1" | cut -d " " -f"$counter">>"$filename"
counter=$((counter+1))
done
It worked, however it creates a vertical list including blank lines between each values of the horizontal list:
0
2
32
323
Why are there blank lines, how can I prevent them?
[Edit] After IsaaC's suggestion, I saw that my question is duplicate of previous one, similar,even same answers were there, so I must close this question. I am appreciated to all contributors.
counter=$((counter+1))
with just((counter++))
. – CR. Mar 13 '22 at 21:28cat inputlist.txt | tr ' ' '\n' > /tmp/vList
. No multiple reads. No need for a script with a loop at all. – frabjous Mar 13 '22 at 21:36cat
alone. :)<inputlist.txt tr …
– Kamil Maciorowski Mar 13 '22 at 21:36od -bc /tmp/vList
– waltinator Mar 13 '22 at 22:39