Find the answer to your Linux question:
Results 1 to 2 of 2
I want to take user specified columns from two files and join them into one file. I store column input from the user into columns1.txt and columns2.txt. I use sed ...
  1. #1
    Just Joined!
    Join Date
    Nov 2008
    Posts
    2

    Help with script....awk

    I want to take user specified columns from two files and join them into one file.

    I store column input from the user into columns1.txt and columns2.txt. I use sed to convert input from "5 6 7" to "$5$6$7"

    I want to use awk for getting the columns...ex
    Code:
    awk ' {print columns1.txt }' file1
    But of course using columns1.txt doesn't work. So how do I take whats inside the file and use it to express inside awk for the columns I want?

    If there is a better way about doing the whole thing, I'm all open for suggestions.

  2. #2
    Linux Newbie
    Join Date
    Jul 2008
    Posts
    181
    Assuming columns1.txt contains something like "5 6 7", try something like this:

    Code:
    cut -f $(sed 's/ \+/,/g' columns1.txt) file1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...