Find the answer to your Linux question:
Results 1 to 4 of 4
Hello all, I've a script with 10-20 lines. The following two taske have to be operated on the script. 1) Find the pattern "#$ -pe <some name> <integer number>". The ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    13

    commands to parse script

    Hello all,

    I've a script with 10-20 lines. The following two taske have to be operated on the script.

    1) Find the pattern "#$ -pe <some name> <integer number>". The line of the pattern starts with "#$".

    2) After finding the presence of this line, the fourth parameter of this line i.e. <integer number> has to be modified within the same script.

    What commands have to be used to achieve the above?

    Thanks,
    Sangamesh

  2. #2
    Linux Newbie
    Join Date
    Jan 2008
    Location
    UK
    Posts
    211
    HI,
    set a variable to take the integer and when found re assign or do whatever you want to do to it and then when the line is output it will have the new value.
    for more help you will have to be a bit more specific with your needs. Unless I am missing something.
    wowbag1

  3. #3
    Just Joined!
    Join Date
    Nov 2008
    Posts
    29
    I believe the AWK will be best where you can search for the field with the help of 'if' of the AWK and $1... $9 [ 1 & 9 are the field number ] and replace the field with the required values redirected to another file required

  4. #4
    Just Joined!
    Join Date
    Nov 2008
    Posts
    29
    I am not sure of the format of your File contents
    Assuming to be like this
    :~/scripts$ cat test
    #$ 123 1234
    # 234 5678
    #&#37; 678 8900

    cat test | awk '{if ($1 == "#$") $3="hello"; print $3}'
    hello
    5678
    8900
    Sorry If I am wrong

Posting Permissions

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