writing to a file using awk

using awk, we can read a specific column of a file.
is it possible to write to a specific column of a file too?
and how? (if possible)

You could do something like

cat filename |while read file
do
echo $file |awk '{print $1,$2,$3"abc",$4}' >> newfile
done

Where abc will be joined onto existing text in column 3.

in fact what i want to do is:
i have 8 files, each have 5 column data
i want to merge these files into 1 file,
so i will get a 1 file with 40 column

use paste command to do that

paste -d " " file1 file2 file3 file4 file5 > newfile

-d specifies the delimiter. i'm assuming that space is the delimiter in the files.

thanks a lot, i got it

Hi Gefa,

Just for you info, you don need the loop in the above command, rather use

because awk processes each line in the file

Gaurav

Thanks Gaurav, I do use both methods, but tend to use mine as it illustrates what the code is doing should anyone else look at it, I agree though that your suggestion is probably more efficient.