Suppose I have a file like
1 3 44 5
2 23 1 44
and I would like to add two columns of 0s after the first two, to get
1 3 0 0 44 5
2 23 0 0 1 44
I could use something like
cat file|(
for ((i=0;i<nlines;i++))
do
read l
echo $(echo $l|cut -d" " -f -2) 0 0 $(echo $l|cut -d " " -f 3-)
done
) >output
where nlines is the known number of lines. But this happens to be extremely slow.
What is the way to do the job in a fast way? Bash, awk or other linux command-line tools are ok.