grep quoted numbers from lines


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers grep quoted numbers from lines
# 1  
Old 02-02-2012
grep quoted numbers from lines

I want to parse the lines and want to extract the double quoted numbers as:

"SQL3149N "72" rows were processed from the input file. "0" rows were
successfully inserted into the table. "0" rows were rejected."

and want the output in 3 variables like
a=72
b=0
c=0

thanks in advance

NOTE: I am using a ksh script

Last edited by mahesh_191; 02-02-2012 at 03:45 AM.. Reason: update the question
# 2  
Old 02-02-2012
Perl, ok?
Code:
perl -ne 'while (/(\"[0-9]+?\")/g) { push (@x, $1) } END { print "@x\n" }' inputfile

This User Gave Thanks to balajesuri For This Post:
# 3  
Old 02-02-2012
Thanks , but I am using a ksh script.
# 4  
Old 02-02-2012
Code:
 
$ nawk '{for(i=1;i<NF;i++){if($i~/rows/){print $(i-1)}}}' test.txt
"72"
"0"
"0"

This User Gave Thanks to itkamaraj For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Make multiple lines into single quoted comma separated Linux

Hi, I want to change a file file1.txt: 1234 3456 2345 6789 3456 2333 4444 As, file2.txt in Linux: '1234','3456','2345','6789','3456','2333','4444' Could someone please help me. (Single liner sed, awk will be welcome!) (7 Replies)
Discussion started by: wiweq05
7 Replies

2. Shell Programming and Scripting

Grep username and get all the lines with thread numbers

I need help to extract the file. If I am entering the user name like abcd@xyz.com, search the username and get the tread number. Once will get thread number all the line having same threadnumber wanted to keep in seperate file. It can be more than thread number for single username. For... (3 Replies)
Discussion started by: nes
3 Replies

3. UNIX for Dummies Questions & Answers

Grep lines with numbers greater than 2 digits at the end of the line

I'm trying to grep lines where the digits at the end of each line are greater than digits. Tried this but it will only allow me to specify 2 digits. Any ideas would greatly be appreciated. grep -i '\<\{3,4,5\}\>' file ---------- Post updated at 05:58 PM ---------- Previous update was at 05:41... (1 Reply)
Discussion started by: jimmyf
1 Replies

4. Shell Programming and Scripting

awk? extract quoted "" strings from multiple lines.

I am trying to extract multiple strings from snmp-mib files like below. ----- $ cat IF-MIB.mib <snip> linkDown NOTIFICATION-TYPE OBJECTS { ifIndex, ifAdminStatus, ifOperStatus } STATUS current DESCRIPTION "A linkDown trap signifies that the SNMP entity, acting in... (5 Replies)
Discussion started by: genzo
5 Replies

5. Shell Programming and Scripting

Take quoted output from one script as quoted input for another script

Hi, I have a script output.sh which produces the following output (as an example): "abc def" "ghi jkl" This output should be handled from script input.sh as input and the quotes should be treated as variable delimiters but not as regular characters. input.sh (processing positional... (2 Replies)
Discussion started by: stresing
2 Replies

6. Shell Programming and Scripting

Perl XML, find matching condition and grep lines and put the lines somewhere else

Hi, my xml files looks something like this <Instance Name="New York"> <Description></Description> <Instance Name="A"> <Description></Description> <PropertyValue Key="false" Name="Building A" /> </Instance> <Instance Name="B"> ... (4 Replies)
Discussion started by: tententen
4 Replies

7. Shell Programming and Scripting

AIX equivalent to GNU grep's -B and -A [print lines after or before matching lines]

Hi folks I am not allowed to install GNU grep on AIX. Here my code excerpt: grep_fatal () { /usr/sfw/bin/gegrep -B4 -A2 "FATAL|QUEUE|SIGHUP" } Howto the same on AIX based machine? from manual GNU grep ‘--after-context=num’ Print num lines of trailing context after... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

8. UNIX Desktop Questions & Answers

grep numbers

Hi all, I am new to unix and struggling to do the below I have few lines in a xml <title>abc:1</title> <description>abc:2</description> <language>abc:3</language> Is it possible to extract only the entire word like abc:1 abc:2 abc:3 instead of the entire line into a new file . Kindly... (3 Replies)
Discussion started by: umapearl
3 Replies

9. UNIX for Dummies Questions & Answers

grep numbers

Hello, I'm trying to grep for digits surrounded by non digits and I'm obviously misinformed. Could someone help me get this sorted out here is what I have that is not working grep -ho '\D(\{11\})\D' *.txt (5 Replies)
Discussion started by: mcgrailm
5 Replies

10. Shell Programming and Scripting

grep for non numbers

Hi, I want to find out whether a string contains non numbers and + and - example : Str="0005000A" - It contains A Str="0005000+" - No problem What I have done is , echo $Str | grep I will have to list out all non numeric characters... (6 Replies)
Discussion started by: shihabvk
6 Replies
Login or Register to Ask a Question