Find the answer to your Linux question:
Results 1 to 7 of 7
please vist the page first awk problem...
  1. #1
    Just Joined!
    Join Date
    Aug 2007
    Posts
    6

    How To Control Sort In Awk?

    please vist the page first
    awk problem

  2. #2
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    Code:
    ...
    print "Thanks to****"substr(topname,RESTART)
    ...
    its RSTART, not RESTART

  3. #3
    Just Joined!
    Join Date
    Aug 2007
    Posts
    6
    Quote Originally Posted by ghostdog74 View Post
    its RSTART, not RESTART
    Thanks in advances.
    I fixed it, but there are still problems.
    anymore good ideas?

  4. #4
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    show your error messages etc...i am not going to guess what happened.

  5. #5
    Just Joined!
    Join Date
    Aug 2007
    Posts
    6
    Quote Originally Posted by ghostdog74 View Post
    show your error messages etc...i am not going to guess what happened.

    ok. please vist again.
    i paste 2 pics of my error on it .
    I can’t print “***THANKS Dan***” but ”***THANKS Dan Savage”.
    print "Thanks to****"substr(topname,RSTART,4)"****" was not a good idea.

    Second, I can’t print the sorted names if the last “Thanks to ……” is needed.
    Listed are their names (sorted by last names) and phone numbers:

    John Goldenrod--(916) 348-4278

    Mike Harrington--(510) 548-1278

    Archie McNichol--(206) 548-1348

    Guy Quigley--(916) 343-6410

    Dan Savage--(406) 298-7744

    Tom Savage--(40 926-3456

    Elizabeth Stachelin--(916) 440-1763

    Thanks to all of you for your continued support!

  6. #6
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    you could try :
    1) sort -k2 instead of sort +1
    2) try split(topname...) instead of match().
    3) instead of system("cat tmp") , you can try
    Code:
    while ( ( getline line < "/path/tmp" ) > 0 )  {
      print line
    }
    however, i suspect you don't have to use this anymore since you have already print them out with the sort...

  7. #7
    Just Joined!
    Join Date
    Aug 2007
    Posts
    6

    Thumbs up

    Quote Originally Posted by ghostdog74 View Post
    you could try :
    1) sort -k2 instead of sort +1
    2) try split(topname...) instead of match().
    3) instead of system("cat tmp") , you can try
    Code:
    while ( ( getline line < "/path/tmp" ) > 0 )  {
      print line
    }
    however, i suspect you don't have to use this anymore since you have already print them out with the sort...
    First, Thanks a lot.
    Secrond,
    Code:
     "sort +1"
    could be ok in freebsd,
    Code:
    "sort -k +1"
    could be right in debian.
    Third,
    Code:
     system("cat tmp")
    may work sometimes, that's quite strange!
    Forth,
    Code:
    while ( ( getline line < "/path/tmp" ) > 0 )  {
      print line
    }
    worked beter than system("cat tmp")


    thanks again!

Posting Permissions

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