How to remove unwanted strings?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to remove unwanted strings?
# 1  
Old 06-27-2011
How to remove unwanted strings?

Hi Guys,

Can someone give me a hand on how I can remove unwanted strings like "<Number>" and "</Number>" and retain only the numbers from the input file below.

INPUT FILE:
Code:
<Number>10050000</Number>
<Number>1001340001</Number>
<Number>1001750002</Number>
<Number>100750003</Number>
<Number>10750004</Number>
<Number>10010005</Number>
<Number>100006</Number>
<Number>10007</Number>
<Number>1000008</Number>
<Number>10009</Number>



DESIRED OUTPUT:
Code:
10050000
1001340001
1001750002
100750003
10750004
10010005
100006
10007
1000008
10009


Thanks in advance.


Br,
Pinpe
# 2  
Old 06-27-2011
Code:
nawk -F'[<>]' '{print $3}' myFile

This User Gave Thanks to vgersh99 For This Post:
# 3  
Old 06-27-2011
Quote:
Originally Posted by vgersh99
Code:
nawk -F'[<>]' '{print $3}' myFile


Perfect! Thanks Dude! Smilie Smilie

Br
Pinpe
# 4  
Old 06-28-2011
with the help of sed..

sed 's/^<.*>\([0-9]*\)<.*/\1/' <file_name>
# 5  
Old 06-28-2011
Code:
%%START CBLOADER CBLOADER                   BRBAI2   000090
01,011600033,011600033,110516,0834,2,90,,2/
02,011600033,011103093,1,110317,0834,,2/
03,105581,,015,+00000416418,,,901,+00000000148,,,922,+000000

00354,,/
03,113806,,015,+00000559618,,,901,+00000000096,,,922,+000000

00621,,/
88,902,+0000000025218,,/
88,100,+0000000000000,0000000,,400,+0000000000000,0000000,/
03,8903816,,015,+00000000000,,,045,+00000000000,,,901,+00000
03,10921029,,015,+00000000000,,,901,+00000000000,,,922,+0000
49,+00000000000000000,00004/
98,+00000425683599208,37275,000148890/
99,+00000425683599208,00001,000148892/

this is my input file,1) my question is
Code 922 can be found on either the ‘03’ Record, the ‘88’ Record, or not found on the Account at all. Always change ‘922’ Code to ‘904’ BAI Code when ever found and move the record to the Output File.
2)
If ‘922’ BAI Code does not exist on ‘03’ Record, ‘901’ BAI Code will be there instead, move ‘03’ Record to Output File untouched.
please send reply as sooon as who write script this file

Last edited by Franklin52; 06-28-2011 at 03:47 AM.. Reason: Please use code tags for code and data samples, thank you
# 6  
Old 06-28-2011
@sgoud

1) what you tried so far ?
2) i asked you to open a new thread (because you suddenly put your question in another person thread)
3) read the Forum rules before post the questions. The UNIX and Linux Forums - Forum Rules

Image
# 7  
Old 06-28-2011
Code:
%%START CBLOADER CBLOADER                   BRBAI2   000090
 01,011600033,011600033,110516,0834,2,90,,2/
 02,011600033,011103093,1,110317,0834,,2/
 03,105581,,015,+00000416418,,,901,+00000000148,,,922,+000000
 
 00354,,/
 03,113806,,015,+00000559618,,,901,+00000000096,,,922,+000000
 
 00621,,/
 88,902,+0000000025218,,/
 88,100,+0000000000000,0000000,,400,+0000000000000,0000000,/
 03,8903816,,015,+00000000000,,,045,+00000000000,,,901,+00000
 03,10921029,,015,+00000000000,,,901,+00000000000,,,922,+0000
 49,+00000000000000000,00004/
 98,+00000425683599208,37275,000148890/
 99,+00000425683599208,00001,000148892/

this is my input file my question is
1)Code 922 can be found on either the ‘03’ Record, the ‘88’ Record, or not found on the Account at all. Always change ‘922’ Code to ‘904’ BAI Code when ever found and move the record to the Output File.
2)
If ‘922’ BAI Code does not exist on ‘03’ Record, ‘901’ BAI Code will be there instead, move ‘03’ Record to Output File untouched. Image

Last edited by Franklin52; 06-28-2011 at 07:41 AM.. Reason: Please use code tags for code and data samples, thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove unwanted commas from a .csv file?

how to remove unwanted commas from a .csv file Input file format "Server1","server-PRI-Windows","PRI-VC01","Microsoft Windows Server 2012, (64-bit)","Powered On","1,696.12","server-GEN-SFCHT2-VMS-R013,server-GEN-SFCHT2-VMS-R031,server-GEN-SFCHT2-VMS-R023"... (5 Replies)
Discussion started by: ranjancom2000
5 Replies

2. Shell Programming and Scripting

Remove unwanted white space

Hi, I have a very big file 25GB with information present in it like $ head ind_stats update index statistics pfirm001.dbo.Office using 200 values go ... (11 Replies)
Discussion started by: sam05121988
11 Replies

3. Shell Programming and Scripting

How to remove unwanted " from string...

I have this Input File with extra double quotes in the middle. Please suggest how to handle this condition. Input File: "123985","SAW CUT CONCRETE SLAB 20"THICK",,"98.57","","EACH","N" "204312","ARMAFLEX-1 3/8 X 3"",,"2.48","","PER FOOT","N" "205745","MISTING HEAD HOLLOW CONE "C"... (3 Replies)
Discussion started by: BICC
3 Replies

4. Shell Programming and Scripting

remove unwanted text using perl

Hello..I have a text file that need to remove unwanted text. This is the original file. No. Time Source Destination Protocol Info 16 0.649949 10.1.1.101 209.225.11.237 HTTP POST /scripts/cms/xcms.asp HTTP/1.1 ... (9 Replies)
Discussion started by: taxi
9 Replies

5. Shell Programming and Scripting

Remove unwanted lines

I have a .xml file, where i need some output. The xml file is like: Code: <?******?></ddddd><sssss>234</dfdffsdf><sdhjh>534</dfdfa>......... /Code I need the output like: code 234 534 . . . /code How can i do it? (5 Replies)
Discussion started by: anupdas
5 Replies

6. Emergency UNIX and Linux Support

Remove Unwanted Libraries - optimizing

We have a huge makefile composing of inclusion of libraries, objects and system libraries to generate a binary. How do we find out that which of the libraries we can remove in the most efficient way? Doing hit and trial method is a waste of time and can during the linking with some post linking... (12 Replies)
Discussion started by: uunniixx
12 Replies

7. Solaris

Remove unwanted packages

I got a system which was installed with SUNWCXall cluster installed on it and i want remove unwanted software like GMNOME, Java Desktop System, Staroffice and numerous other softwares .. i want to do an automated removal of these packages where its uninstalled by itself ..from the is there any... (4 Replies)
Discussion started by: fugitive
4 Replies

8. UNIX for Advanced & Expert Users

How to Remove the unwanted Blank Lines

I have a file with the below data, i would like to remove the end blank lines with no data. I used the below commands but could not able to succeed, could you please shed some light. Commands Used: sed '/^$/d' input.txt > output.txt grep -v '^$' input.txt > output.txt input.txt file... (5 Replies)
Discussion started by: Ariean
5 Replies

9. Shell Programming and Scripting

Remove unwanted XML Tags

I have set of sources and the respective resolution. Please advice how to resolve the same using Unix shell scripting. Source 1: ======= <ext:ContactInfo xmlns:ext="urn:AOL.FLOWS.Extensions"> <ext:InternetEmailAddress>AOL@AOL.COM</ext:InternetEmailAddress> </ext:ContactInfo> Resoultion... (1 Reply)
Discussion started by: ambals123
1 Replies

10. Shell Programming and Scripting

Remove unwanted data?

Hi Can any one help me remove the unwanted data? I would want to remove the complete event id 4910 ( the type there is INFO), that means, I have to remove starting from 7th - 19th lines. can any one of you please help? Thanks, (24 Replies)
Discussion started by: hitmansilentass
24 Replies
Login or Register to Ask a Question