sed-question delete everthing after a couple of numbers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed-question delete everthing after a couple of numbers
# 1  
Old 10-22-2008
sed-question delete everthing after a couple of numbers

Hi,

I've a textfile with a lots of numbers. After some numbers are comments.
I want delete these comments with sed, but dont know the correct pattern.

for example (my textfile):
PHP Code:
3202 mycomment
292
-is way to low
1
#correct
3  #my whitespace comment
4229 // comment
20.201 // numbers with dots are also in my file
202.02 miaumiau
1.234.99 
'''''''FOO 
So I want to delete ALL stuff after ne last number ...

correct ouput:
PHP Code:
3202
292
1
3
4229
20.201
202.02
1.234.99 
# 2  
Old 10-22-2008
Code:
sed 's/\(^[\.0-9]*\)[^.0-9]*/\1/g' infile

# 3  
Old 10-22-2008
thanks a lot
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Filter and delete numbers in a list

Hello, I've got a list of a single column numbers like 3000.66 3002.55 3062.23 3242.12 etc... I would like to delete all numbers higher than for example 3060.00 and lower than 2990.00 How can I do that? Thanks in advance (2 Replies)
Discussion started by: Board27
2 Replies

2. Shell Programming and Scripting

Delete several lines if the first line contain numbers > 200

I have a file of the following format: $data1 size 1278 dataw datat datau datai $data2 size 456 datak dataf datat datay datal $data3 size 154 datag datas datat datar datas (8 Replies)
Discussion started by: FelipeAd
8 Replies

3. Shell Programming and Scripting

sed pattern fails to delete line of numbers

We are using Red Hat Linux. I have a flat file with among other things, the following lines, which appear occasionally throughout the file: Using sed, I delete this line: L;L;L;L;R;R;R;L;R;L;R;R;R;L;L;L With: /^;;;;;*/d Works fine every time. However, I cannot delete... (6 Replies)
Discussion started by: bloomlock
6 Replies

4. Shell Programming and Scripting

Couple of easy questions for experts on awk/sed

Hello Experts.. I have 3-4 C codes with Oracle SQL statements embedded. All the SQL statements starts with EXEC SQL keyword and ends with ;. I want to extract all the SQL statements out of these codes. I did awk '/^EXEC SQL/,/\;/' inputFile (I use this on all of the codes individually). That... (2 Replies)
Discussion started by: juzz4fun
2 Replies

5. UNIX for Dummies Questions & Answers

How to delete columns with numbers in an excel file?

Dear all, I have one file (see below) with more then 100 columns and 2500 rows, and need only column which has GType in label with Alphabets, please help me to remove these columns with numbers. input file is n.201.GType n-201.Theta n-201.R n_1.GType n_1.Theta n_1.R... (6 Replies)
Discussion started by: AAWT
6 Replies

6. UNIX for Dummies Questions & Answers

Urgent_need to delete columns with numbers

Dear all, I have one file (see below) with more then 100 columns, and need only column which has GType in label with Alphabets, please help me to remove this columns with numbers. input file is n.201.GType n-201.Theta n-201.R n_1.GType n_1.Theta n_1.R n_7.GType ... (1 Reply)
Discussion started by: AAWT
1 Replies

7. Shell Programming and Scripting

Delete lines with line numbers.

Hi, I have a file will 1000 lines.... I want to deleted some line in the file... like 800-850 lines i want to remove in that... can somebody help me..? thanks. (2 Replies)
Discussion started by: Kattoor
2 Replies

8. Shell Programming and Scripting

how to delete records with the given line numbers

I have a file which has about 10000 records and I need to delete about 50 records from the file. I know line numbers and am using sed '134,1357,......d' filename > new file. It does not seem to be working. Please Advice (5 Replies)
Discussion started by: mad_man12
5 Replies

9. Shell Programming and Scripting

delete numbers in a filename

I have some files where numbers are part of like eg 1add1.txt 23sub41.txt etc I want to remove numbers from the filenames(whereever it may be). I used echo `ls *.txt | sed -e "s///"` But its removing first digits like 1add1.txt becomes add1.txt My intention is to make 1add1.txt... (3 Replies)
Discussion started by: villain41
3 Replies

10. UNIX for Dummies Questions & Answers

everthing is a file

Hello, I`m new with the Unix and Linux stuff. But I want to learn something about it. Now`s my question what does: everthing is a file means?? Could some body explane this to me? thx (2 Replies)
Discussion started by: Loodgieter
2 Replies
Login or Register to Ask a Question