I have a file with two columns. Each line in this file has a different size of words
awk \'$5=$9\' FS="#" OFS="\\t" file1**
Tomato#Vegetable
Another awk, that reads the file once, hashes the records to memory (expected that you have enough memory available) and format and outputs in the end:
$ awk -F\# '{ # define record separator
a[NR]=$1 # store 1st field
b[NR]=$2 # store 2nd field
m=((n=length($1))>m?n:m) # figure out the max length of 1st field
}
END { # in the end
for(i=1;i<=NR;i++) # iterate stored fields
printf "%-" m+4 "s%s\n",a[i],b[i] # output
}' file
Output:
Tomato Vegetable
Orange Fruit
Cucumber Vegetable
Sweat Potato Fruit