Results 1 to 4 of 4

Thread: help in script

  1. #1
    Join Date
    Sep 2003
    Posts
    23

    Question Unanswered: help in script

    Hello
    I need help for the accomplishment of a script. Of the result of the list of files in a directory unix, that they are different every day I have to refill different fields in another pattern file and redirecct to a final file
    In other words

    ls -1

    pepe.g123
    john.g456
    tom.g789

    hello I,m field1 hello I,m pepe
    hello I,m field2 hello I,m g123
    hello I,m field3 -----------> hello I,m john
    bye field4 bye g456
    bye field5 bye tom
    bye field6 bye g789



    I am doing it with a loop(for) of the name of file and later with the commands (sed) and (cut) but I find solve limitations that I am not to solve. I dont know well the command (awk), Im sure will help me yo solve the problem.

    Thanks in advance

  2. #2
    Join Date
    Sep 2003
    Posts
    23
    Sorry
    In my previous mail the example was not written well I think that this understands better

    ls -1

    pepe.g123
    john.g456
    tom.g789

    pattern file......................... final file

    hello I,m field1..................> hello I,m pepe
    hello I,m field2..................> hello I,m g123
    hello I,m field3..................> hello I,m john
    bye field4..........................> bye g456
    bye field5..........................> bye tom
    bye field6..........................> bye g789

  3. #3
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    12

    Smile

    In the crudest form, you can get the fields value by using :-

    ls | while read line
    do
    echo $line | awk -F"." '{print $1}'
    echo $line | awk -F"." '{print $2}'
    done

    Hope this helps.
    Thanks and Regards
    Karthik R

  4. #4
    Join Date
    Sep 2003
    Posts
    23

    Smile

    This works well, now I must find the way to change to the fields
    obtained within the file pattern. I hope to obtain it.

    Thank you very much by your aid

Posting Permissions

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