Output following Command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dilip1983
    New Member
    • Jan 2008
    • 21

    Output following Command

    Hi All

    I am using the following command to get the output like this
    home1
    pandadk
    sandbox
    odm
    odm_daa
    pub_odm_daa_tes t1
    run

    Code:
    echo "/home1/pandadk/sandbox/odm/odm_daa/pub_odm_daa_test1/run"|awk '{split($0,a,"/"); for(i=1; i<=NF; i++) print a[i]}'
    But it is returning me nothing.

    Please advise.

    Thanks
    Dilip
    Last edited by Nepomuk; Sep 15 '08, 08:16 AM. Reason: Please use [code] ... [/code] tags
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2
    Hi,
    Please look at your for loop...
    What is 'NF' here?
    Have you tried replacing 'NF' with some constant?
    You would definitely get the answer.

    Regards,
    Ash

    Comment

    • ghostdog74
      Recognized Expert Contributor
      • Apr 2006
      • 511

      #3
      Code:
      echo "/home1/pandadk/sandbox/odm/odm_daa/pub_odm_daa_test1/run" | tr "/" "\n"
      or
      Code:
       echo "/home1/pandadk/sandbox/odm/odm_daa/pub_odm_daa_test1/run" | awk  '1' RS="/"

      Comment

      Working...