The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
vi to remove lines in file kjbaumann UNIX for Dummies Questions & Answers 2 03-13-2009 03:40 AM
remove lines from file bluemoon1 Shell Programming and Scripting 9 11-09-2007 01:40 AM
how to remove specific lines from a file bluemoon1 Shell Programming and Scripting 17 10-07-2007 10:40 PM
To remove the extra spaces in unix Sho UNIX for Dummies Questions & Answers 4 05-04-2006 05:58 AM
Remove Duplicate Lines in File Teh Tiack Ein Shell Programming and Scripting 5 01-12-2006 08:30 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-29-2005
CamTu CamTu is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 46
remove extra lines in the file

Hi,

I have some files, with some extra lines in weird characters on the top and bottom of the. I want to get rid of those line. Is there a way I can do that?

example of the input file. I want to get rid of those lines in bold
Code:
[?25h[?4l[?1l[?3h[?3h
                                                                                                
                                                       07:46 AM Tue Mar 29 2005 
                                                                      Page:   1 
                                                                                
                                     SCAD                                       
                                 sale report                                    
                            Location Sales Report                               
                    03/28/05 12:00AM Thru 03/28/05 11:59PM                      






                           Blackboard Inc.                                  End  



[?3l 
in pick_p 1
in pick_p 1
in pick_p 1
in pick_p 1
in pick_p 1
in pick_p 2
in pick_p 3
in pick_p 4
in pick_p 5
in pick_p 6
in pick_p 7
in pick_p 8
in pick_p 9
in pick_p 0
in pick_p 11
in pick_p -2
our pick_p
Thanks

CT
  #2 (permalink)  
Old 03-29-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
do 'od -c yourFile' and post the results, pls.
  #3 (permalink)  
Old 03-29-2005
CamTu CamTu is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 46
here is the results from "od -c myfile"

Code:
0000000 033   (   B 033   [   ?   2   5   h 033   [   2   J 033   [   ?
0000020   4   l 033   [   ?   1   l 033   [   0   m 033   [   1   ;   2
0000040   4   r 033   [   ?   3   h 033   [   ?   3   h  \n            
0000060                                                                
*
0000200                                                      \n        
0000220                                                                
*
0000300                       0   7   :   4   5       A   M       T   u
0000320   e       M   a   r       2   9       2   0   0   5      \n    
0000340                                                                
*
0000440                       P   a   g   e   :               1      \n
0000460                                                                
*
0000600  \n                                                            
0000620                                                                
0000640                           S   C   A   D                        
0000660                                                                
*
0000720      \n                                                        
0000740                                                                
0000760               s   a   l   e       r   e   p   o   r   t        
0001000                                                                
*
0001040          \n                                                    
0001060                                                               L
0001100   o   c   a   t   i   o   n       S   a   l   e   s       R   e
0001120   p   o   r   t                                                
0001140                                                                
0001160              \n                                                
0001200                                   0   3   /   2   8   /   0   5
0001220       1   2   :   0   0   A   M       T   h   r   u       0   3
0001240   /   2   8   /   0   5       1   1   :   5   9   P   M        
0001260                                                                
0001300                  \n  \n      \n  \n  \n                        
0001320                                                                
0001340                       B   l   a   c   k   b   o   a   r   d    
0001360   I   n   c   .                                                
0001400                                                                
0001420                           E   n   d      \f      \n  \n  \r 033
0001440   [   ?   3   l  \n   i   n       p   i   c   k   _   p       1
0001460  \n   i   n       p   i   c   k   _   p       1  \n   i   n    
0001500   p   i   c   k   _   p       1  \n   i   n       p   i   c   k
0001520   _   p       1  \n   i   n       p   i   c   k   _   p       1
0001540  \n   i   n       p   i   c   k   _   p       2  \n   i   n    
0001560   p   i   c   k   _   p       3  \n   i   n       p   i   c   k
0001600   _   p       4  \n   i   n       p   i   c   k   _   p       5
0001620  \n   i   n       p   i   c   k   _   p       6  \n   i   n    
0001640   p   i   c   k   _   p       7  \n   i   n       p   i   c   k
0001660   _   p       8  \n   i   n       p   i   c   k   _   p       9
0001700  \n   i   n       p   i   c   k   _   p       0  \n   i   n    
0001720   p   i   c   k   _   p       1   1  \n   i   n       p   i   c
0001740   k   _   p       -   2  \n   o   u   r       p   i   c   k   _
0001760   p  \n
0001762
Thanks

CT
  #4 (permalink)  
Old 03-29-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Code:
nawk 'BEGIN{chr=sprintf("\033")} $0 !~ chr' myFile
  #5 (permalink)  
Old 03-29-2005
CamTu CamTu is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 46
vgersh99,

That works for only the first line in the file, but those last lines still there. I want those to be remove also (those that in bold in the first post):

Code:
0001340                       B   l   a   c   k   b   o   a   r   d    
0001360   I   n   c   .                                                
0001400                                                                
0001420                           E   n   d      \f      \n  \n  \r 033
0001440   [   ?   3   l  \n   i   n       p   i   c   k   _   p       1
0001460  \n   i   n       p   i   c   k   _   p       1  \n   i   n    
0001500   p   i   c   k   _   p       1  \n   i   n       p   i   c   k
0001520   _   p       1  \n   i   n       p   i   c   k   _   p       1
0001540  \n   i   n       p   i   c   k   _   p       2  \n   i   n    
0001560   p   i   c   k   _   p       3  \n   i   n       p   i   c   k
0001600   _   p       4  \n   i   n       p   i   c   k   _   p       5
0001620  \n   i   n       p   i   c   k   _   p       6  \n   i   n    
0001640   p   i   c   k   _   p       7  \n   i   n       p   i   c   k
0001660   _   p       8  \n   i   n       p   i   c   k   _   p       9
0001700  \n   i   n       p   i   c   k   _   p       0  \n   i   n    
0001720   p   i   c   k   _   p       1   1  \n   i   n       p   i   c
0001740   k   _   p       -   2  \n   o   u   r       p   i   c   k   _
0001760   p  \n
0001762
Thanks

CT
  #6 (permalink)  
Old 03-29-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Quote:
Originally Posted by CamTu
vgersh99,

That works for only the first line in the file, but those last lines still there. I want those to be remove also (those that in bold in the first post):

Thanks

CT
this is NOT entire correct - the code removes ANY line containing '033' octal character [ESC]. You have the FIRST line AND line number 30 with '033' octal.

All other lines contain no 'escape' character - therefore they're NOT removed.

You can remove the 'trailers' this way - but it's NOT a generic solution:
Code:
nawk 'BEGIN{chr=sprintf("\033")} $0 !~ chr && !/^in pick/ && !/^our pick/' myFile

Last edited by vgersh99; 03-29-2005 at 12:56 PM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0