Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recent content by frankli

  1. frankli

    gawk RS using regex

    Thanks very much for all the tips and comments. You guys are great!
  2. frankli

    gawk RS using regex

    Hi feherke, There is still something missing if use RT, if you could elaborate, gawk 'BEGIN { RS = "(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Dec|Nov)" } /ERROR_/ { print NR " " RT " " $0 }' input Mon Oct line1 line2 line3 (ERROR_1) Tue Nov line4 line5 Fri Dec...
  3. frankli

    gawk RS using regex

    Thanks for your input Annihilannic! I did a mistake by telling the half story, the reason I wanted to use RS shortcut is ... I have another pattern to match in the desire output lines, something like, desire output 1 Mon Oct line1 line2 line3 (ERROR_1) 2 Tue Nov line4 line5 3 Fri Dec...
  4. frankli

    gawk RS using regex

    Hello List, I use regex while define RS in gawk, everything is working fine except I don't know the trick to print the original RS, please see if you can help. source: Mon Oct line1 line2 line3 Tue Nov line4 line5 Fri Dec line6 line7 statement gawk 'BEGIN { RS =...
  5. frankli

    can I use regex while define $/ ?

    Thanks for the comment.
  6. frankli

    can I use regex while define $/ ?

    Hello List, I m trying to print the multiple lines to one base on certain pattern e.g. Source: Sun Feb 8 line1 line2 line3 Mon Feb 9 line4 line5 Tue Feb 10 line6 line 7 line 8 Target Sun Feb 8 line1 line2 line3 Mon Feb 9 line4 line5 Tue Feb 10 line6 line7 line8 I can accomplish this...
  7. frankli

    print the 2nd line above the pattern

    Thanks Annihilannic. Just FYI, for the 2nd option, if there is more than one line above the pattern line it will give out wrong output, Try it against below 123 456 abc def ghi jkl mno pqr stu abc vwx yza the output of "awk '/abc/ { found=NR } NR==found+2'" would be 456 ghi yza
  8. frankli

    print the 2nd line above the pattern

    below will print all the match line for above case ... but can not handle the memory choking ... awk '{a[NR]=$0} /abc/ {b[NR]=NR+2} END {for (i in b) if (i != null) {print a[b[i]]}}' input/file
  9. frankli

    print the 2nd line above the pattern

    following above thought I want to print the 2nd line below the pattern line but I can only pick up the 1st match line not all of them ... something is wrong please comment, abc def ghi jkl mno pqr stu abc vwx yza use abc to print ghi, yza, but I only get ghi use below ... awk '{a[NR]=$0}...
  10. frankli

    print the 2nd line above the pattern

    Thanks a lot! Regards, -frank
  11. frankli

    print the 2nd line above the pattern

    Hi PH, It works. Thanks. I also tried below it works too, please give a tip on how to understand NR%3 awk '{a[NR]=$0}/klm/{print a[NR-2]}' /path/to/input Regards, -frank PS. Would like to know the thought of retrive 2nd line below the patten line too .. just came up ... Thanks.
  12. frankli

    print the 2nd line above the pattern

    Just wandering if there is a easy way in awk to print the 2nd line above the pattern line abc def hij klm locate klm to print out def. Thanks in advance to my favorite AWK list!
  13. frankli

    Solaris 10 link_mode

    Hi folks, I m wondering how I can tell the link_mode on a Solaris 10 server, seems link_mode, link_speed, link_status are not supported in Solaris 10. Thanks. /usr/sbin/ndd -get /dev/ce \? ? (read only) instance (read and write) adv_autoneg_cap...
  14. frankli

    process 3 files and substitution

    Brilliant! Appreciate!
  15. frankli

    process 3 files and substitution

    forgot a pair of curly brackets, it works, however, got another problem ... some of the $v_nameX do have "/" in side, e.g. v_name8=10.1.1.2/swe/eai:2003, if have any suggestion please comment. Thanks! file1=venv.old file2=venv.new file3=vfile.matrix awk ' FILENAME=="'$file1'"...

Part and Inventory Search

Back
Top