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
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 08: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

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 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?
  #2 (permalink)  
Old 10-08-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
Use cut:

Code:
cut -c 7- file > newfile
Regards
  #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.
  #4 (permalink)  
Old 10-08-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
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'
  #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!
  #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
  #7 (permalink)  
Old 10-17-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,419
Code:
sed -n 's/[^$]*\$//p'
Sponsored Links
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 03:15 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