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...
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...
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 =...
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...
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
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
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}...
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.
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!
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...
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'"...
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...
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...
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...
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!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.