The UNIX and Linux Forums  

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
How to replace any char with newline char. mightysam Shell Programming and Scripting 5 09-18-2008 08:15 PM
extraction of last but one char hidnana Shell Programming and Scripting 5 02-14-2008 07:22 AM
char c = 882 useless79 High Level Programming 1 07-30-2007 05:16 AM
char *p and char p[]. arunviswanath High Level Programming 4 07-20-2006 02:11 AM
\n char in C C|[anti-trust] High Level Programming 1 05-05-2005 06:15 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-08-2008
mcW mcW is offline
Registered User
 

Join Date: Sep 2008
Posts: 19
sed - delete until char x

Hi,

I got a Textfile contains hundreds of lines like this:

PHP Code:
3 02 8293820 0 22 22 
All I need is this:

PHP Code:
293820 0 22 22 
So i decided to delete until the first '8' comes up. But how I can realize that?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-08-2008
Moderator
 

Join Date: Feb 2007
Posts: 3,549
Use cut:

Code:
cut -c 7- file > newfile
Regards
Reply With Quote
  #3 (permalink)  
Old 10-08-2008
mcW mcW is offline
Registered User
 

Join Date: Sep 2008
Posts: 19
The only pattern I can use is the _first_ 8. The lines differ in the number of whitespaces, chars before the first 8 etc.
Reply With Quote
  #4 (permalink)  
Old 10-08-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
 

Join Date: Sep 2007
Location: Germany
Posts: 1,681
If I got it right, you want to cut off all digits until the first "8" shows up, including itself?:

Code:
sed -n 's/[^8]*8//p'
Reply With Quote
  #5 (permalink)  
Old 10-08-2008
mcW mcW is offline
Registered User
 

Join Date: Sep 2008
Posts: 19
Yes, thats right. Works perfect. Thanks a lot!
Reply With Quote
  #6 (permalink)  
Old 10-17-2008
mcW mcW is offline
Registered User
 

Join Date: Sep 2008
Posts: 19
Quote:
Originally Posted by zaxxon View Post
If I got it right, you want to cut off all digits until the first "8" shows up, including itself?:

Code:
sed -n 's/[^8]*8//p'
Now Ive a new problem. Cut off all chars until the first "$" shows up, inc itself.
I tested: sed -n 's/[^\$]*\$//p', but didnt work, what ive to do in this case?

thanks in advance
Reply With Quote
  #7 (permalink)  
Old 10-17-2008
danmero danmero is offline Forum Advisor  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 901
Code:
sed -n 's/[^$]*\$//p'
Reply With Quote
Google The UNIX and Linux Forums
Reply

Bookmarks

Tags
None

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:




All times are GMT -4. The time now is 08:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66