Removing Numbers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Removing Numbers
# 1  
Old 04-25-2012
Removing Numbers

Hi,
Below is a scattered representation of numbers .
Code:
[0][0]1[0]  2[0]
[0][0]
  1[0]1     2[0]2  

  1[0]1      2[0]2  
[0][0]1[0]  2[0]
[0][0]
[0][0]1[0]  2[0]
[0][0]
  1[0]1      2[0]2  

[0][0]1[0]  2[0]
  1[0]1     2[0]2


I need to display only the following sequence "[0]" and delete of the remainder from the output. The output should look like
Code:
[0][0][0]  [0]
[0][0]
  [0]     [0]

  [0]      [0]  
[0][0][0]  [0]
[0][0]
[0][0][0]  2[0]
[0][0]
  [0]      [0]  

[0][0][0]  [0]
  [0]     [0]

Plz help me out
Thanks.

Last edited by Franklin52; 04-26-2012 at 04:46 AM.. Reason: Please use code tags
# 2  
Old 04-25-2012
one way sed s:[1-9]::g infile
# 3  
Old 04-25-2012
Negating RE's is always tricky and the added complexity of matching "[0]" smacks of homework.

Here is a brute force awk solution that chops out the bits you want ([0] and space).
Code:
awk '{while(match($0, "[[]0]| ")) {
    printf "%s", substr($0, RSTART, RLENGTH)
    $0=substr($0,RSTART+RLENGTH);
    } printf "\n"}' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Decimal numbers and letters in the same collums: round numbers

Hi! I found and then adapt the code for my pipeline... awk -F"," -vOFS="," '{printf "%0.2f %0.f\n",$2,$4}' xxx > yyy I add -F"," -vOFS="," (for input and output as csv file) and I change the columns and the number of decimal... It works but I have also some problems... here my columns ... (7 Replies)
Discussion started by: echo manolis
7 Replies

2. UNIX for Dummies Questions & Answers

Removing PATTERN from txt without removing lines and general text formatting

Hi Everybody! First post! Totally noobie. I'm using the terminal to read a poorly formatted book. The text file contains, in the middle of paragraphs, hyphenation to split words that are supposed to be on multiple pages. It looks ve -- ry much like this. I was hoping to use grep -v " -- "... (5 Replies)
Discussion started by: AxeHandle
5 Replies

3. UNIX for Dummies Questions & Answers

Print numbers and associated text belonging to an interval of numbers

##### (0 Replies)
Discussion started by: lucasvs
0 Replies

4. Shell Programming and Scripting

Removing comma just from numbers

Hi Guys, I want to remove commas from just the numbers in the file. So both sides of the comma should be numbers. Input file Johan 1,234 nb jan 123,3 hi, hello, bye 12,345,54 hejhej Desired output: Johan 1234 nb jan (6 Replies)
Discussion started by: Johanni
6 Replies

5. Shell Programming and Scripting

the smallest number from 90% of highest numbers from all numbers in file

Hello All, I am having problem to find what is the smallest number from 90% of highest numbers from all numbers in file. I am having file with thousands of lines and hundreds of columns. I am familiar mainly with bash but I am open to whatever suggestion witch will lead to the solutions. If I... (11 Replies)
Discussion started by: Apfik
11 Replies

6. UNIX for Dummies Questions & Answers

Replace US numbers with European numbers

hey, I have a file with numbers in US notation (1,000,000.00) as well as european notation (1.000.000,00) i want all the numbers to be in european notation. the numbers are in a text file, so to prevent that the regex also changes the commas in a sentence/text i thought of: sed 's/,/\./'... (2 Replies)
Discussion started by: FOBoy
2 Replies

7. Shell Programming and Scripting

Removing Line numbers

Hi all, I have a file consisting of lines in such a format: separated by space and M1 EOS for fullstop (.) ] e.g M1 I M1 have M1 a M1 file M1 consisting M1 of M1 lines M1 in M1 such M1 a M1 format M1 EOS M2 This M2 is M3 an (4 Replies)
Discussion started by: my_Perl
4 Replies

8. Shell Programming and Scripting

read numbers from file and output which numbers belongs to which range

Howdy experts, We have some ranges of number which belongs to particual group as below. GroupNo StartRange EndRange Group0125 935300 935399 Group2006 935400 935476 937430 937459 Group0324 935477 935549 ... (6 Replies)
Discussion started by: thepurple
6 Replies

9. UNIX for Dummies Questions & Answers

seperating records with numbers from a set of numbers

I have two files one (numbers file)contains the numbers(approximately 30000) and the other file(record file) contains the records(approximately 40000)which may or may not contain the numbers from that file. I want to seperate the records which has the field 1=(any of the number from numbers... (15 Replies)
Discussion started by: Shiv@jad
15 Replies

10. Shell Programming and Scripting

removing all numbers from file

I have one me.txt file like aaa 765 gfre 534 jhk 321 cvvb 98 hftg 2 bdg2 hfuk 65 etc.. now I want to remove all numbers form that file using shell script and out put will be printed in me1.txt output: aaa gfre jhk cvvb hftg bdg hfuk please help me. (2 Replies)
Discussion started by: rinku
2 Replies
Login or Register to Ask a Question

Featured Tech Videos