Hello All
I'm trying to change one string from a file contening this patern:
xxxx-xxxx
4 numbers - end 4 other numbers
This is a sample of the file:
LDR 00679 am a2200205 4500
=001 3617
=008 030219s2000\\\\xxx|||||\||||\00|\0\spa\d
=020 \\$a0211-1942
=041 \\$aCastell�
=093 \\$a19/02/2003
=095 \\$a12/11/2001
=100 \\$aGorrotxategi Anieto, Xabier$91930
=245 \\$aArte paleol�tico parietal de Bizcaia
as you see there is a line :=020 \\$a0211-1942
So I would like to detect deep in a big file with a lot of records like this. and every row with xxxx-xxxx replace the code =020 by =022
I know that sed can do this but I have no idea how... Some one can help ??
Thanks a lot
sed -i.bak 's:=020 \(\\\\$a[0-9]\{4\}-[0-9]\{4\}\):=022 \1:' file
Hi
thanks for this rapid answer... Whooaw
So I guess that the way to grab the xxxx-xxxx patern is:
(\\\\$a[0-9]\{4\}-[0-9]\{4\}\)
The start is parentesis write?
I do not anderstand the \\\\ before $a
Then I anderstand this:
[0-9]\{4\}-[0-9]\{4\
it means.. get numeric numbers length 4... isn't it?
Thanks again
---------- Post updated at 03:50 AM ---------- Previous update was at 03:43 AM ----------
Hello again
and...if I want to check de print before replace?
May this sintaxe ok?
sed -p'\(\\\\$a[0-9]\{4\}-[0-9]\{4\}\) \1:' file
Thanks
Hello,
Following may help you in same.
awk '{match($0,/.*[0-9][0-9][0-9][0-9]\-[0-9][0-9][0-9][0-9]/); a=substr($0,RSTART+4,RLENGTH); {if(a){print "022" a}}}' check_data_check_rem_check12113
Output will be as follows.
022 \\$a0211-1942
Thanks,
R. Singh
1 Like
Hi
very usefull. Thank you very much !!
Does any one can paste url of a tutorial sed and awk for beginners??
jajaja This tools seem to be very powerfull.
Cheers