Name: htnkd Date: July 26, 2005 at 07:38:25 Pacific Subject: awk script for search and replace OS: xp CPU/Ram: 1G
Comment:
I have a file with thousands of records in it. Each record in the file being of a fixed length of 190 bytes.
Example: 0003006315B000000002100601X646000000054717154-12700911700 00Telkwa Trailer Park 0003006317B000000003000601X646000000054717154-12700911700 00Tyhee Trailer Park 0003006613B000000002000601X646000000053242950-13181814600 00Beban Trailer Park 0003006848B000000006000601X646000000054163445-12542196600 00Freeport Trailer Park What I would like to do is for each record position 11 == B and somewhere starting at positon 80 for 49 bytes there is the word "Trailer". I want to replace position 28 for 3 with "xxx" for that record (Example X646 would become Xxxx). I want to do this for the entire file.
any help on how to get this to work. I am new to this and I have been doing sed on each individual record and this would take forever.
For example, in the two lines below, you want only the first line:
No. America North America
In regular expressions, a dot means any single character. You need to precede the dot with a backslash which will "escape" its special meaning and be taken as an actual dot: