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

Troubles with sub ?

Status
Not open for further replies.

malpa

Technical User
Feb 8, 2004
122
CO
Hi,

I have many unblock files in ascii format. I want to remove some strings.

Between these strings there are registers with a 203 bytes of length.

I´m using sub funtion. This funtion replaced them, but this funtion added some characters.

This strings could be in everywhere.

String number one (Length of string 240 bytes.)

dot (.) means any character

VOL1TTVOL................................NORTE..................................HDR1TTFILE01.........TTVOL.......
...............................................HDR2F020300203030AXE...../....................................................
..

registers
1104 186794
77 03300564411801000050614073550000024000020000005 0BOGONORCO24/1/201ETB1F7OFUS1PBI00700 0 0102002
0 06395460203
.
.
.
1104 186794
77 03300564411801000050614073550000024000020000005 0BOGONORCO24/1/201ETB1F7OFUS1PBI00700 0 0102002
0 06395460203



String number two (Length of string 160 bytes.)

EOF1TTFILE01.........TTVOL......................................................EOF2F020300203030AXE...../......
................................................


This is the programm

removing the firts string
awk ' { gsub(/VOL1TTVOL................................NORTE..................................HDR1TTFILE01.........TTVOL.......
...............................................HDR2F020300203030AXE.....\/....................................................
../,"",$0);print} ' $file > file_one

removiong the second string
awk ' { gsub(/EOF1TTFILE01.........TTVOL......................................................EOF2F020300203030AXE.....\/......
................................................/,"",$0);print} ' file_one > file_two

After that, those strings don´t appear but the size of the file is increased.

After, I use fold command.
fold -w 203 file > file


Thanks for your valuable input

malpa
 
Hi,

Ok, I have troubles with gsub y sub in awk. I had to use perl to do the same, but I didn´t understand why gsub didn´t function?


The trouble was solved.


malpa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top