The UNIX Forums
"Join the Network of UNIX System Users"


 
Subject: line too long using awk or sed or tr
kitlindell
Newbie
Rank: 1



UID 224
Digest Posts 0
Credits 0
Posts 50
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 18, 2007 11:13 AM  Profile | P.M. 
line too long using awk or sed or tr



line too long using awk or sed or tr



goodmorning,

i have mks toolkit (k-shell) running on a windows server. on it i have a c program that in a true unix environment works fine, but here it adds an extra '0000000000000016000a' in various places in the file that the c program produces that i need to remove.

here is what the file looks like when i pg it:

code:
00000000000000840022003a00013a40313a98263a013af63af2423af03af2423af03a13043a0705163a08233a20513af03a  f53a113af0
00000000000000840022003a00013a26983a98273a013af73af4903af03af4903af03a26983a0705163a12063a20493af03a  f73af63af0
00000000000000840022003a00013a26983a98283a013af53af1073af03af1073af03a26983a0705163a13283a20483af03a  f13a123af0

note that the length of the line exceeds the width of the screen and pg simply does not display the rest of the line; this file shows 17 very long lines.

from the windows environment, here is what it looks like when i use notepad:

code:
000000000000004c0022163a000000003a00013af03af03af03af6103a08023a070516220a
0000000000000016000a
000000000000004c0022163a000000003a00033af03af03af03af6083a08033a070516220a
0000000000000016000a
000000000000004c0022163a000000003a00043af03af03af03af6073a08043a070516220a
0000000000000016000a
000000000000004c0022163a000000003a00023af03af03af03af6073a08063a070516220a
0000000000000016000a
000000000000004c0022163a000000003a00013af03af03af03af6093a08123a070516220a

so i have tried sed:

code:
sed '/0000000000000016000a/d' tl000110.ip.out > new.out

and i get a zero byte new.out. i have tried this identical sed command on a simple text file where i put '00123' strewn throughout and it worked fine.

i tried awk:

code:
awk '{gsub("0000000000000016000a","",$0)}' tl000110.ip.out > new.out

and i get this message:

code:
awk: line 0 (nr=0): line too long: limit 20000

i tried using tr, but i could only ever get it to work on a character by character basis, so when i asked for it to delete '0000000000000016000a' it also removed all instances of the numbers 0,1,6 and the letter a.


can anyone here think of a way to remove these errant entries from this file that has long lines?

thanks for the help!


Top
CountryBoy
Newbie
Rank: 1



UID 98
Digest Posts 0
Credits 0
Posts 27
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 18, 2007 11:13 AM  Profile | P.M. 
just guessing, give this a try:
tr '\r' '\n' < tl000110.ip.out | sed '/0000000000000016000a/d' > new.out
Top
 

 

All times are GMT, the time now is Jul 31, 2010 03:39 AM

Powered by Discuz! 5.0.0  © 2001-2006 UNIX Forums
Processed in 0.004965 second(s), 8 queries

Clear Cookies - Contact Us - UNIX Help - Archiver - WAP