Extracting and printing data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extracting and printing data
# 1  
Old 01-14-2011
Extracting and printing data

Hi

I have the following data :
Code:
           <Cell id="34A" ref="ds:/BTS:34/Cells/Cell:34A"/>
          <Cell id="34B" ref="ds:/BTS:34/Cells/Cell:34B"/>
          <Cell id="34C" ref="ds:/BTS:34/Cells/Cell:34C"/>

I would like to print this data in the following format :
Code:
BTS:34 Cell:34A.

I'm still very new and trying to learn how extract specfic data and print .
Please assist.

Last edited by Scott; 01-14-2011 at 06:06 AM.. Reason: Please use code tags
# 2  
Old 01-14-2011
Code:
awk -F'[/"]' '{print $5,$7}' inputFile

# 3  
Old 01-14-2011
Code:
perl -lne '/\/([^\/]+).*(Cell:[^\"]+)/;print "$1 $2"' file

This User Gave Thanks to bartus11 For This Post:
# 4  
Old 01-14-2011
Thanks Guys
# 5  
Old 01-18-2011
Hi

Thanks for all the help.I really appreciate it.

I wanted how would I alter this command - awk -F'[/"]' '{print $5,$7}' inputFile such that it does not print duplicates.

Thanks
# 6  
Old 01-18-2011
Try:
Code:
awk -F'[/"]' '{$0=$5" "$7}!A[$0]++' infile

# 7  
Old 01-18-2011
Thanks Scrutinizer.

Could you please explain how the code works.

I'm not too sure whats happening - $0=$5" "$7}!A[$0]++

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with extracting data within parentheses

This is my input file: a|b|c(ef)|g|h(km)|p My output file should look like: a|b|ef|g|km|p That is, pipe is the delimiter. The data within pipe must be displayed as it is but if it encounters any data within parentheses, then only the data within parentheses has to be displayed ( the data... (2 Replies)
Discussion started by: ksatish89
2 Replies

2. Shell Programming and Scripting

Q:Perl Extracting & Printing Security Token

I have a script which is supposed to log in to my vB account and print my security token, however doesn't seem to work globally. The logging in works perfectly just will not retrieve and print the security token for every forum I log in to. Code Below: #!/usr/bin/perl use LWP::UserAgent; ... (8 Replies)
Discussion started by: AndrewTwain
8 Replies

3. UNIX for Dummies Questions & Answers

Extracting data from file

I am trying to compare the data in lines 3 & 5 to see if they match up to the '-S570' (see first code set, all proprietary information has been removed from code set) spawn telnet Trying ... Connected to CA-LOS1234-ASE-S570.cl . Escape character is '^]'. CA-LOS1234-ASE-S570 Username: ... (1 Reply)
Discussion started by: slipshft
1 Replies

4. Shell Programming and Scripting

extracting data

I have a txt file of the following format >ab_ qwerty >rt_ hfjkil >Ty2 hglashglkasghkf; >P2 aklhfklflkkgfgkfl >ui_ vnllkdskkkffkfkkf >we32 vksksjksj;lslsf'sk's's .... ..... I want to split this big file based on the header (>) (5 Replies)
Discussion started by: Lucky Ali
5 Replies

5. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

6. Shell Programming and Scripting

extracting data from a string

Hi there, I have a bunch of vlan tagged network interfaces that are named as follows e1000g111000 e1000g99001 e1000g3456000 nge2002 where the 'e1000g' and 'nge' parts of the name are the driver, the red and blue bits above define the VLAN and the last digit on the end defines the... (3 Replies)
Discussion started by: rethink
3 Replies

7. Shell Programming and Scripting

Extracting data from tables......

HOw to extracts data from tables in database. Merges them into one output file. This output file is loaded into another tables in database. (1 Reply)
Discussion started by: nari.bommi
1 Replies

8. UNIX for Dummies Questions & Answers

Help with extracting data and plotting

I have attached a txt file, what I would like to be able to do is: 1. Extract Data from Columns labeled E/N and Ko into a new file 2. Then in the new file I would like to be able to plot E/N on the X axis and Ko on the y axis. 3. Lastly I would like to be able to extract multiple data sets and... (6 Replies)
Discussion started by: gingburg
6 Replies

9. Shell Programming and Scripting

Extracting Data From Sendmail

Hello, Like many Unix shops, Our systems send Email alerts whenever things break. I have been tasked with writing a shell script to get the email alerts from Sendmail, extract the Date / Time, From, Subject, and message text from the emails and punch them into a MySQL DB. This will then be... (3 Replies)
Discussion started by: calex
3 Replies

10. Shell Programming and Scripting

Extracting certain data from a sentence

How do I delete text in each line from the first character up to a certain pattern, ie. 'qmuser.' and then delete from the next occurence of a dot to the end of the sentence For example: - LTSB Renewal Notice Travel Pack --- d \qmaster\spool1\qmuser.8664_LM245_20031216094308.ps.0 From this... (7 Replies)
Discussion started by: dbrundrett
7 Replies
Login or Register to Ask a Question