awk command help

December 8, 2010 at 07:36:11
Specs: Linux x86_64
I have two files want to copy the last column of the last line of them to two different files in different lines and columns.
let say if the last number of the first two files are 1 and 3 I want to have a new file which contains
and an other file
1 3

See More: awk command help

Report •

December 8, 2010 at 14:09:16
In awk save the last field and at the END, print out the last field a newfile. Then, use xargs to print the output of the newfile eliminating the carriage returns:


rm -f newfile otherfile

for ind in file1 file3
   awk ' {
   END {
      # print last lines last field
      printf("%s\n", savefield)
   } ' $ind  >> newfile

# create the otherfile
xargs < newfile > otherfile

Report •
Related Solutions

Ask Question