computing
  • 0

Solved Use The Cut & Paste Commands To Swap Fields 2 And 3 My Table

  • 0

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?

Share

1 Answer

  1. 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.

    • 0