Solved Use the cut & paste commands to swap fields 2 and 3 my table

May 15, 2012 at 07:23:38
Specs: UNIX
Use the cut & paste commands to swap fields 2 and 3 my table. Call it mytable(same
name) & print the new file, my table IN SHELL?

See More: Use the cut & paste commands to swap fields 2 and 3 my table

Report •

#1
May 16, 2012 at 09:08:47
✔ Best Answer
This is obivously a homework problem or you would use perl or awk to swap fields 2 and 3.

How about making a effort? I will get you started to cut the first 3 fields into seperate files, use the cut command:

# column 1
cut -d " " -f 1 mytable.txt > col1.txt

Now do the same thing for the 2nd and 3 columns
cut -d " " -f 2 mytable.txt > col2.txt
cut -d " " -f 3 mytable.txt > col3.txt

And to get the rest of the file from column 4 on:
cut -d " " -f 4- > colrest.txt

Now, use the paste command to glue the parts together in the proper order.



Report •
Related Solutions


Ask Question