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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  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'"...
  16. frankli

    process 3 files and substitution

    when I print cmd2 got sed -e "s///g" path1/file1.old > path1/file1 it seems old[$i] new[$i] can not be passed to sed, Any idea? Thanks!
  17. frankli

    process 3 files and substitution

    THANKS PH! I ran it after modification, got below error ... still under troubleshooting. It can mv file to file.old, all the values are in the array, when did sed it will empty the file instead of substitute the certain value ... when I tried with the value in sed manually it works sed -e...
  18. frankli

    process 3 files and substitution

    Hello list, Let me explain what I want to do first ... the goal is to substitute several old values to several new values in a file. the matrix file records the filename (first column) and the variables need to be substituted cat vfile.matrix path1/file1 v_name1 v_name2 v_name3 na v_name5...
  19. frankli

    want to use awk for this

    actually don't have to do the substitution outside of awk, just wondering cat vfile file1 v_name1 v_name2 v_name3 na v_name5 na v_name7 file2 v_name1 na v_name3 na v_name5 v_name6 na file3 v_name1 v_name2 na na na na na cat venv v_name1=v1 v_name2=v2 v_name3=v3 v_name4=v4 v_name5=v5 v_name6=v6...
  20. frankli

    want to use awk for this

    hello PHV and all, by using NR==FNR{split($0,a,"=");v[a[1]]=a[2];next} can I use the v[] array outside of awk but in the same script? I m thinking of using awk to obtain variable from 2 files but need to do the substitution outside awk. Thanks. Regards!

Part and Inventory Search

Back
Top