Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How can I do this with AWK

  1. Sep 16, 2009 #1
    Hi,
    I need to modify a shell script and add the following into it:
    location: 200 200 1
    location: 200 200 2
    location: 200 200 3
    ---------
    ---------
    ---------
    location: 200 200 449
    location: 200 200 500

    I thought using some awk command one could produce the series 1,2,.... 500 in the last column of all the 500 lines. Can anyone help me with that command.
    Thank you very much.
     
  2. jcsd
  3. Sep 16, 2009 #2

    sylas

    User Avatar
    Science Advisor

    if you just want a filter to add numbers to the end of each line...

    awk '{ print $0, ++x; }'
     
  4. Sep 16, 2009 #3
    Hi,
    Thanks!
    I want to write a small script or an awk command (or if any other way) that will produce a file which has all those 500 lines in it.
     
  5. Sep 16, 2009 #4

    sylas

    User Avatar
    Science Advisor

    Here's a shell script

    Code (Text):
    #!/bin/sh
    for (( n=1 ; n <= 500 ; n++ )) do
        echo location: 200 200 $n
    done
     
  6. Sep 16, 2009 #5
    Thank you sooo much.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How can I do this with AWK
  1. LaTeX, how can i? (Replies: 6)

Loading...