I use the following awk script to create 5 columns out of a single column:
How would I modify the script so that each column is sorted downward and not across?
This is what i'm running right now:
Current output:
U10021 U10027 U10028 U10034 U10062
U10072 U10073 U10082 U10107 U10166
U10171 U10252 U10258 U10510 U10511
.. .. .. .. ..
.. .. .. .. ..
Desired output:
U10021 U10072 .. .. ..
U10027 U10073 .. .. ..
U10028 U10082 .. .. ..
U10034 U10107 .. .. ..
U10062 U10166 .. .. ..
You get the point.
.. = UNNNNN
Code:
BEGIN {
count=0
cols=5
}
{
len=length($0)
pad=substr(" ",1,15-len)
LINE=LINE " " $0 pad
count=count+1
if (count == cols) {
print LINE
count=0
LINE=""
}
}
END { if (count > 0) {
print LINE}
}
How would I modify the script so that each column is sorted downward and not across?
This is what i'm running right now:
Code:
cat MyOneColumnList.txt | sort | awk -f mkCol.awk
Current output:
U10021 U10027 U10028 U10034 U10062
U10072 U10073 U10082 U10107 U10166
U10171 U10252 U10258 U10510 U10511
.. .. .. .. ..
.. .. .. .. ..
Desired output:
U10021 U10072 .. .. ..
U10027 U10073 .. .. ..
U10028 U10082 .. .. ..
U10034 U10107 .. .. ..
U10062 U10166 .. .. ..
You get the point.
.. = UNNNNN