Grep Question


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Grep Question
# 1  
Old 01-30-2013
Grep Question

My grep returns a row of data like this:

Code:
75=20130130;60=074338;61=985;511=55473883;452=115439;62=196;267=1;

Is there a way for the grep to only return 60="something" and 511="something" ?

Thanks in advance.

Last edited by Scrutinizer; 01-30-2013 at 01:05 PM.. Reason: code tags
# 2  
Old 01-30-2013
Here is a solution using awk
Code:
awk -F\; '{for(i=1;i<=NF;i++) { if($i ~ /^60/) print $i; if($i ~ /^511/) print $i; }}' filename

# 3  
Old 01-30-2013
Thank you. I tried this in a windows cmd:

Code:
U:\>gunzip -c awk -F\; '{for(i=1;i<=NF;i++) { if($i ~ /^60/) print $i; if($i ~ /^511/) print $i; }}'L:\System1\SailLogger_20130130* L:\System2\SailLogger_20130130* L:\System3\SailLogger_20130130* | grep 35=SailOrderEntry

And recieved this error:


'The system cannot find the file specified.'

Am I doing something wrong ?

Last edited by Scrutinizer; 01-30-2013 at 01:04 PM.. Reason: code tags
# 4  
Old 01-30-2013
Yes, you are. Just pipe the output of gunzip to awk program:
Code:
gunzip -c L:\System1\SailLogger_20130130* | awk -F\; '{for(i=1;i<=NF;i++) { if($i ~ /^60/) print $i; if($i ~ /^511/) print $i; }}'

# 5  
Old 01-30-2013
Thanks again. Tried this:
Code:
U:\>gunzip -c L:\System1\SailLogger_20130130* | awk -F\; '{for(i=1;i<=NF;i++) { if($i ~ /^
60/) print $i; if($i ~ /^511/) print $i; }}'

And received this error:

The system cannot find the file specified.

Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by vbe; 01-30-2013 at 01:26 PM.. Reason: code tags
# 6  
Old 01-30-2013
That error clearly states that the file: L:\System1\SailLogger_20130130* does not exists.
# 7  
Old 01-30-2013
Thanks again. When I run this:

Code:
U:\>gunzip -c L:\System1\SailLogger_20130130* | grep 35=SailOrderEntry

I get results like this:

Code:
75=20130130;60=120249;61=349;511=69668561;452=379647;62=510;267=1;89=281;6019=NFS1;191=XY/
0060/Z71/511579/1;76=226S0F1;109=0226;35=SailOrderEntry;2146=120249;78=0226SF1;510=559054;
6004=U9;2164=APL4;297=USMarketOrder;54=Buy;38=3;2165=None;2171=Unknown;8008=Day;9150=0549;
9104=NBBOControlAndOlaRouting;1=NoAccNum;5077=PublicCustomer;77=Opening;6003=Speculator;91
05=None;58=XY/0060/Z71/511579/13030NCMMP;6146=SLW   130201C35.00;6176=BOX00APL4U91;

So the file does exist - correct ?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Question on grep

Hello all, I'm trying to grep the string "scott" from all files whose names are like srvr*.log and that were created "Nov 15"...I'm trying the following command but throws an error message...seems like the syntax is incorrect.. grep scott < ls -l srvr*.log|grep "Nov 15" Thanks for your... (9 Replies)
Discussion started by: luft
9 Replies

2. Shell Programming and Scripting

Question about grep

is there anyway i can ask grep to only get the first line? as in the top command line line 1 <-- just grep this line line 2 line 3 ---------- Post updated at 04:24 PM ---------- Previous update was at 04:19 PM ---------- nvm.. found out that i can do it with |head (12 Replies)
Discussion started by: Nick1097
12 Replies

3. Shell Programming and Scripting

Question about grep

can anyone tell me what the \/$ means? from grep \/$ (8 Replies)
Discussion started by: Nick1097
8 Replies

4. Shell Programming and Scripting

grep question please

i have files with "DOMAINSOLVER ACMS" with any number of spaces in between the two words on its own line and i can find it with the following: grep -c "DOMAINSOLVER* ACMS" $FILENAMEbut i need to exclude any lines matching: "$DOMAINSOLVER". i've tried a variety of quoting and escaping with no luck.... (4 Replies)
Discussion started by: crimso
4 Replies

5. Shell Programming and Scripting

grep question

Hello, Is there a way in grep to remember patterns? For eg: int a,b,c,d,a; If a variable is declared twice, like in the previous example, I should be able to print only those lines. Is there a way to print only the lines where the variable name occurs more than once, using grep... (1 Reply)
Discussion started by: prasanna1157
1 Replies

6. UNIX for Dummies Questions & Answers

grep question

Instead of using the following command #dmesg | grep -v sendmail | grep -v xntpd How can I use just one grep -v and give both arguments. Please suggest thanks (4 Replies)
Discussion started by: Tirmazi
4 Replies

7. Shell Programming and Scripting

grep question

hello people, All my servers have 4 mounts with this norme. For example, if my hostname is siroe. df -h | grep `hostname` /dev/dsk/c1t3d0s6 404G 399G 800M 100% /siroe3 /dev/dsk/c1t2d0s6 404G 399G 800M 100% /siroe2 /dev/md/dsk/d6 20G 812M 19G ... (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

8. UNIX for Dummies Questions & Answers

Grep Question

Hello Everybody, I have files; yyyymmdd.log which the data look like this; "Txid=9426043&MsgTxt=Thankyou&UserId=john&Password=jh2501" "Txid=9426150&MsgTxt=Thankyou&UserId=john&Password=jh2501" . . . "Txid=9426200&MsgTxt=Thankyou&UserId=john&Password=jh2501" Question 1: How to... (3 Replies)
Discussion started by: nazri76
3 Replies

9. UNIX for Dummies Questions & Answers

question about grep

I want to search for a word from the root directory using grep command. I am searching for a word called batch in cd /vol directory.The vol directory has so many sub-directories and I want to see all the files having the name as batch. This what I tried .. /vol/ % grep -i *batch* But it is... (4 Replies)
Discussion started by: ANAMIKA56
4 Replies

10. UNIX for Dummies Questions & Answers

grep question

what is the format for grep if I want to search from the current directory and through all its subdirectories?:) (3 Replies)
Discussion started by: pkappaz
3 Replies
Login or Register to Ask a Question