Find the answer to your Linux question:
Results 1 to 7 of 7
Hi, I have following row in a file (this file conatins only one row) No.of.rows|9 I need to get number i.e '9' from the above line.More specifically, I need to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2007
    Posts
    18

    Red face Help in grep command


    Hi,

    I have following row in a file (this file conatins only one row)

    No.of.rows|9

    I need to get number i.e '9' from the above line.More specifically, I need to get value after the '|'(pipe) delimiter.

    Could you please help me how to get that number from the file.

    Thanks in advance!

    Regards,
    Vishnu

  2. #2
    Just Joined!
    Join Date
    Dec 2006
    Posts
    52
    Use awk:
    awk -F | '{ print $2}'

  3. #3
    Just Joined!
    Join Date
    Feb 2007
    Posts
    18
    Hi ,

    I am using footer.txt file which consist of the
    No.of.rows|9
    row
    As per your suggastion am using the command like

    footer.txt | awk -F | '{ print $2}'

    but its throwing an error.

    Could you please help me out here!

    Thanks and Regards,
    Vishnu.

  4. #4
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    Quote Originally Posted by GVishnu
    Hi ,

    I am using footer.txt file which consist of the
    No.of.rows|9
    row
    As per your suggastion am using the command like

    footer.txt | awk -F | '{ print $2}'

    but its throwing an error.

    Could you please help me out here!

    Thanks and Regards,
    Vishnu.
    its like this
    Code:
    awk -F | '{ print $2}' footer.txt

  5. #5
    Just Joined!
    Join Date
    Feb 2007
    Posts
    18
    Hi,

    According to your suggastion I tested in the server where the footer file exists but its throwing an error like

    [root@cognos.int.pic paymaster]# awk -F | '{ print $2}' footer.txt
    -bash: { print $2}: command not found
    awk: option requires an argument --


    could you please help me out

    Many Thanks,

  6. #6
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    Quote Originally Posted by GVishnu
    Hi,

    According to your suggastion I tested in the server where the footer file exists but its throwing an error like

    [root@cognos.int.pic paymaster]# awk -F | '{ print $2}' footer.txt
    -bash: { print $2}: command not found
    awk: option requires an argument --


    could you please help me out

    Many Thanks,
    sorry pls try this
    Code:
    awk -F "|" '{ print $2}'  footer.txt

  7. #7
    Just Joined!
    Join Date
    Feb 2007
    Posts
    18
    Thank you very much !! Its working fine.

    Kind Regards,
    Vishnu.

Posting Permissions

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