sed - delete until char x


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed - delete until char x
# 1  
Old 10-08-2008
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  
Old 10-08-2008
Use cut:

Code:
cut -c 7- file > newfile

Regards
# 3  
Old 10-08-2008
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  
Old 10-08-2008
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  
Old 10-08-2008
Yes, thats right. Works perfect. Thanks a lot!
# 6  
Old 10-17-2008
Quote:
Originally Posted by zaxxon
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  
Old 10-17-2008
Code:
sed -n 's/[^$]*\$//p'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete Word between two Char.

HI Guys, I have Input:- A nput A.txt 000100/port_xcu_dev_6/port_0_dev_7 000100/port_xcu_dev_6/port_1_dev_10 000100/port_xcu_dev_2/port_2_dev_8 000100/port_xcu_dev_3/port_3_dev_11 000100/port_xcuv_9/port_4_dev_9 ... (3 Replies)
Discussion started by: pareshkp
3 Replies

2. Red Hat

How to remove a special char using sed

consider this is my sample file format. in this i want to remove ^@ with space . please help me in this problm 7305,1310184890,0,0,12,201370,FCASTBHBR0 ,XX ,2,1,2,0,^@,1,1,0,3,1303862400,0,1577923199,1,10,FCASTOR SEED EX-BHABHAR ... (2 Replies)
Discussion started by: ponmuthu-lnx
2 Replies

3. Shell Programming and Scripting

sed returns error "sed: -e expression #1, char 18: unterminated `s' command"

Hello All, I have something like below LDC100/rel/prod/libinactrl.a LAA2000/rel/prod/libinactrl.a I want to remove till first forward slash that is outputshould be as below rel/prod/libinactrl.a rel/prod/libinactrl.a How can I do that ??? (8 Replies)
Discussion started by: anand.shah
8 Replies

4. Shell Programming and Scripting

Delete Last Char from first World

HI File A.txt Abcde12351 Kalel Abcde12962 Basil Abcde21653 Fosil Output B.txt Abcde1235 Abcde12351 Kalel Abcde1296 Acbde12962 Basil Abcde2165 Acbde21653 Fosil Thanks (1 Reply)
Discussion started by: asavaliya
1 Replies

5. Shell Programming and Scripting

Gen random char then sed replacements

Hey guys, I need to first generate some random characters, which I am already doing perfectly as follows: randomize=`cat /dev/urandom | tr -dc "a-z0-9" | fold -w 6 | head -n 1` This is where I am stuck...I need to sed replace some static values with those random characters, but I need each... (4 Replies)
Discussion started by: holyearth
4 Replies

6. Shell Programming and Scripting

sed: -e expression #1, char 21: unterminated `s' command

I have read many threads, but I still didn't find the right answer. May be i didn't find the right thread, though are so many threads for the same question. Basically the situation is - find date in a file and replace it with another date. (its not homework, its part of lot of a big processing,... (10 Replies)
Discussion started by: avinthm
10 Replies

7. Shell Programming and Scripting

Removing special char's with sed

Hi, I've a txt file which contains the following kind of listed data 18971 ./aosrp18.r 15340 ./aosrp12.r 22996 ./aosrp08.r 17125 ./aosrp06.r I'm trying to get rid of the ./ in the file and have tried the following with sed but I'm not getting the correct result... I'm not sure what way... (7 Replies)
Discussion started by: Jazmania
7 Replies

8. UNIX for Dummies Questions & Answers

delete first two " char

Hi, I need to delete the char " from a line but only the first 2 example: JPY,0,XS0122118481,CCDO,IFI_CCDO,"2,210,000,000","2,210,000,000",0.00 result: JPY,0,XS0122118481,CCDO,IFI_CCDO,2,210,000,000,"2,210,000,000",0.00 How may I go about doing this? Thanks (2 Replies)
Discussion started by: UNovIX
2 Replies

9. Shell Programming and Scripting

sed issues with strange char

Hi all, I try to create a shell script to had the xiti tag at the end of servals web pages just before the <body/> tag. here is my script : #!/bin/bash ################################################################## rm -R /home/hibern/TEMP/hibern cp -R... (5 Replies)
Discussion started by: hibern
5 Replies

10. Shell Programming and Scripting

sed escape char

Hi, For the following complex code , <!-- ... (2 Replies)
Discussion started by: fed.linuxgossip
2 Replies
Login or Register to Ask a Question