04-10-2007
find pattern and replace another field
HI all
I have a problem, I need to replace a field in a file, but only in the lines that have some pattern, example:
100099C01101C00000000059394200701CREoperadora_TX
100099C01201C00000000000099786137OPERADORA_TX2
in the example above I need to change the first field from 1 to 2 only if the line has the CRE pattern. so the lines will be:
200099C01101C00000000059394200701CREoperadora_TX
100099C01201C00000000000099786137OPERADORA_TX2
Could you help me, how to do this with perl or with awk
Regads
Marcelo
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have a file 'test.out' with contents:
1|1|10|10|I|asdf|
2|1|10|10|I|sdfg|
4|1|10|10|I|hgfj|
34|0|10|10|I|sdg|
I want to modify the fifth column with value 'I' to 'A' for only the last line. Below is what I expect to see:
1|1|10|10|I|asdf|
2|1|10|10|I|sdfg|
... (3 Replies)
Discussion started by: ChicagoBlues
3 Replies
2. Shell Programming and Scripting
I've got a log file, of the format
Name: network1
Dropped packets: 15618
Dropped packets for IPv6: 27
Dropped packets: 74
Dropped packets for IPv6: 0
Failed RADIUS Authentication procedures: 0
Failed RADIUS Accounting procedures: 0
Name: network2
Dropped packets: 1117
... (18 Replies)
Discussion started by: Yorkie99
18 Replies
3. Shell Programming and Scripting
Hi all,
I have a huge file and I need to get ride of the fields 6-11 and replace the blanks in field 5 with a missing value(99999).
159,93848,5354,343,67898,45,677,5443,434,5545,45
677,45545,3522,244,
554,54344,3342,456,
344,43443,2344,444,23477... (12 Replies)
Discussion started by: GoldenFire
12 Replies
4. Shell Programming and Scripting
Hello All,
I have a file with contents like
apple|ball|charlie|David|
England|France|Germany|
Ireland|Japan|King|London|
Man|Nancy|Orange|
here the column delimiter is |
so if any of the lines/rows in the file has 3 only records (last field is empty), i want to place a | at the end of... (4 Replies)
Discussion started by: vinredmac
4 Replies
5. Shell Programming and Scripting
Hi,
I have a date/time field in my file. I have to search in all the records and append a timestamp to it, if the timestamp is missing in that field. Is there a possible awk solution for this?
Field date format
File1
====
1|vamu|payer|2007-12-02 02:01:30|bcbs|... (5 Replies)
Discussion started by: machomaddy
5 Replies
6. UNIX for Dummies Questions & Answers
Hi all,
I have a TAB separated file like this:
sample.rpt:
54 67 common/bin/my/home {{bla bla bla}} {bla bla} Replace Me
89 75 bad/rainy/day/out {{ some bla} } {some bla} Dontreplace Me
......
......
I wish to do a regexp match on the 3rd... (2 Replies)
Discussion started by: newboy
2 Replies
7. Shell Programming and Scripting
hi,
i having a file with | seperated in which i need to search char in 3rd column and replace with null. i need to replace only the coulmn where character occurs in 3rd field
for eg:
file1.txt
xx|yy|xx|12
output file:
xx|yy||12 (5 Replies)
Discussion started by: rohit_shinez
5 Replies
8. Shell Programming and Scripting
$ cat /cygdrive/d/Final2.txt
1,A ,Completed, 07.03_23.01 ,Jun 30 20:00
2,BBB,Pending,,
3,CCCCC,Pending,,
4,DDDDD,Pending,,
5,E,Pending,,
6,FFFF,Pending,,
7,G,Pending,,
In the above file 4th field is date which is in MM.DD_HH.MIN format and I need to convert it to as it is there in 5th... (1 Reply)
Discussion started by: Amit Joshi
1 Replies
9. Shell Programming and Scripting
I have posted this again as old post is closed and I am not able to reopen. so please consider this new post
Input File :
1,A,Completed,06.02_19.36,Jun 30 20:00
2,BBB,Failed,07.04_05.12,Jul 21 19:06
3,CCCCC,New,07.21_03.03,Jul 26 12:57
4,DDDDD,Pending,,
I wast output file as:
... (7 Replies)
Discussion started by: Amit Joshi
7 Replies
10. Shell Programming and Scripting
Hello all
I have two files.
1. Pattern.txt - It contains patterns to be matched. It has large number of patterns to be matched.
Cat Pattern.txt
Ram
Shyam
Mohan
Jhon
I have another file which has actual data and records are delimted by single or multiple spaces.
2.... (8 Replies)
Discussion started by: krsnadasa
8 Replies
MEWLS(1) General Commands Manual MEWLS(1)
NAME
mewls - Message scanner for Mew
SYNOPSIS
mewls [options] [folder [range]]
DESCRIPTION
The mewls utility extracts necessary fields from messages stored in folders. This command is necessary for Mew to implement the asynchro-
nous feature.
The options are as follows:
-a Print all necessary fields when picking.
-b dir Set the Mail home to dir.
-c dir Set the News home to dir.
-d field
Set th field to be extracted to field.
-e command
Specify an external command to fetch mailbox.
-m options
Specify options for command.
-f fields
Specify fields to display.
-h Display this help message.
-i file Set the input stream to file.
-l length
Set the field max length to be extracted to length. The default value is 3. 0 means no limit.
-n Don't use fstat().
-p pattern
Specify the pick pattern.
-s src Set message source to src : '+folder range'.
-w time Set the wait_for timer to timer (microsecond).
-v Display the version.
Definitions of the symbols above are as follows:
range N | [start]-[end] | last:N
pattern 'key=val' | 'key!=val' | '!<pattern>' | '(<pattern>)' | '<pattern>&<pattern>' | '<pattern>|<pattern>'
BUGS
If a field is long, only the beginning three lines are extracted by default.
March 17, 2001 MEWLS(1)