To Fetch values from String

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers To Fetch values from String
# 1  
Old 05-04-2017
To Fetch values from String

Dears, I have string like below in my csv file

Code:
<someTechnicalDetails><someTechnicalDetails>HSI</someTechnicalDetails,1234564
<someTechnicalDetails><someTechnicalDetails>Voice</someTechnicalDeta,12345673
<someTechnicalDetails><someTechnicalDetails>IPTV</someTechnicalDetai,12345673

and I need out put like below

Code:
HSI,1234564
Voice, 12345673
IPTV,12345673

Please let me know how can i achieve this

Last edited by RudiC; 05-04-2017 at 07:22 PM..
# 2  
Old 05-04-2017
something along these lines to start with:
Code:
awk -F'[<>,]' '{print $(NF-2), $NF}' OFS=, myFile.csv

# 3  
Old 05-04-2017
Code:
perl -pe 's/^.*>|<\/[^,]+//g' mirwasim.csv
HSI,1234564
Voice,12345673
IPTV,12345673

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to fetch values in csv

I need to fetch below values from this file. (1 Reply)
Discussion started by: nit42
1 Replies

2. Shell Programming and Scripting

Fetch the values based on a Key using awk from single file

Hi, Please help to fetch the values for a key from below data format in linux. Sample Input Data Format 11055005|PurchaseCondition|GiftQuantity|1 11055005|PurchaseCondition|MinimumPurchase|400 11055005|GiftCatalogEntryIdentifier|Id|207328014 11429510|PurchaseCondition|GiftQuantity|1... (2 Replies)
Discussion started by: mohanalakshmi
2 Replies

3. Shell Programming and Scripting

Fetch parent value based on column values

Hi All, I am trying to achieve the below logic, could you please help me in this. In second row 2nd column I've Value JC2 and the same JC2 is 4th row 1st column.So I need to replace JC2 value in 4th row with JC2 2nd row's 1st column. Input: Job1,JC1 Job1,JC2 Job1,JC3 JC2,JA1... (6 Replies)
Discussion started by: unme
6 Replies

4. Shell Programming and Scripting

Fetch Valid String

Hi All, How to fetch the particular row based on my search command. For example Source Column Column A Column B 001,56123456 002,57123456 003,123456 Expected Output: 003,123456 To get this output I tried below mentioned function grep '123456' filename.txt (4 Replies)
Discussion started by: suresh_target
4 Replies

5. Shell Programming and Scripting

How to fetch values from a line in a file to variables in UNIX?

Hi, I need to assign values from a lines in a file into variables in unix, i am using Korn shell. I tried the below script from posts but i am unable to fetch every value in a variable. #! /usr/bin/ksh #for file in test.txt; do IFS=$'\|' I=1 while read -a val do echo... (15 Replies)
Discussion started by: karthikram
15 Replies

6. Shell Programming and Scripting

Cut & Fetch word from string

I have a file with some SQL query, I want to fetch only Table Name from that file line by line. INPUT FILE SELECT * FROM $SCHM.TABLENAME1; ALTER TABLE $SCHM.TABLENAME1 ADD DateOfBirth date; INSERT INTO $SCHM.TABLENAME1 (CustomerName, Country) SELECT SupplierName, Country FROM $SCHM.TABLENAME2... (2 Replies)
Discussion started by: Pratik Majithia
2 Replies

7. Shell Programming and Scripting

How to fetch a string between two different strings?

Hi I am having a file with content as, <name>usrname</name> <value>ravistej</value> <name>pswd</name> <value>asdfgzxcv</value> . . . . <name>abc</name> <value>xyz</value> From this file, i want to fetch the string present between '<value>' and '</value>' and store the values into... (9 Replies)
Discussion started by: tejastrikez
9 Replies

8. Shell Programming and Scripting

Fetch the rows with match string on a fixed lenth text file - NO delimiters

Hi I am trying to fetch the rows with match string "0000001234" Input file looks like below: 09 0 XXX 0000001234 Z 1 09 0 XXX 0000001234 Z 1 09 0 XXX 0000001234 Z 1 09 0 XXX 0000001234 Z 1 09 0 XXX 0000001234 Z 1... (6 Replies)
Discussion started by: nareshk
6 Replies

9. Shell Programming and Scripting

How to fetch variable value in if block and to compare it with certain string

Hi, I am trying to execute this command if ; then but getting error .Some problem with reteriving the value of $exception_info. Please help.Its urgent. thanks (4 Replies)
Discussion started by: khushboo
4 Replies

10. Shell Programming and Scripting

fetch string and insert later

"are you billy_smith ?" replace with "are you billy_smith ? my name is billy_smith" how to fetch the name "billy_smith" and using it later I need sed script to do this, any one can help? Thanks (6 Replies)
Discussion started by: playinmel.com
6 Replies
Login or Register to Ask a Question