Need specific output from script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need specific output from script
# 1  
Old 10-31-2013
Need specific output from script

Hallo Team,

I have *.csv files and this is the command that i run to find out how many occurances i have in this files. For example i run this command below:

Code:
-bash-3.2$ grep "ACCOUNT NOT FOUND" BW-CDR-2013* |grep -v INCE|cut -f32 -d"," | sort -u
BRY
CORONATION-CONF
DOE-CONF
HIP-ADVTECH-AP
HIP-ADVTECH-NET-MENLYN
HIP-GEMS-NELSPRUIT
HIP-KELLY-JHB
HIP-MGS-JHB
HIP-ROD-LAB
HIP-YKK-JHB
JSE-CONF
PEARSON-CPT
SANLAM-SKY-DBN-BENEFITS
SCRANTON-PA
SI_FUTURES_PANGEA
THECAMPUS-GSC
TRANSUNION-CONF
TTS-FAX

As you can see i am using field 32 to get my results but the problem is the output changes every 4 hours. Sometimes you can have 24 lines returned or 100 lines returned.

So from the output i get i type in this command for example:

Code:
-bash-3.2$ grep HIP-ADVTECH-NET-MENLYN BW*2013*|wc -l
248

So i would like to automate everything where by field 32 would be fed into command 2.

I hope i am making sense.
# 2  
Old 10-31-2013
Quote:
Originally Posted by kekanap
So i would like to automate everything where by field 32 would be fed into command 2.
What is command 2? Or, why does it matter how lines command 2 gets?
# 3  
Old 10-31-2013
Do you run these commands with glob turned off? - For one issue, the * metacharacters would break grep. So, as presented, I cannot understand how those commands would work at all.
# 4  
Old 10-31-2013
Command 1

Code:
-bash-3.2$ grep "ACCOUNT NOT FOUND" BW-CDR-2013* |grep -v INCE|cut -f32 -d"," | sort -u
BRY
CORONATION-CONF
DOE-CONF
HIP-ADVTECH-AP
HIP-ADVTECH-NET-MENLYN
HIP-GEMS-NELSPRUIT
HIP-KELLY-JHB
HIP-MGS-JHB
HIP-ROD-LAB
HIP-YKK-JHB
JSE-CONF
PEARSON-CPT
SANLAM-SKY-DBN-BENEFITS
SCRANTON-PA
SI_FUTURES_PANGEA
THECAMPUS-GSC
TRANSUNION-CONF
TTS-FAX

Command 2
Code:
-bash-3.2$ grep HIP-ADVTECH-NET-MENLYN BW*2013*|wc -l
248

---------- Post updated at 02:46 PM ---------- Previous update was at 02:44 PM ----------

Jim the grep in my command interpretes * as everything.
# 5  
Old 10-31-2013
I'm not sure exactly what you're asking, but I suspect you want grep -F or xargs -I.
# 6  
Old 10-31-2013
Nor am I sure what you want to achieve. If you want to grep all BW*2013* files for the results of your previous grep, you could try grep's -f (optain patterns from file) option using "-" for the file thus pointing at stdin:
Code:
grep "ACCOUNT NOT FOUND" BW-CDR-2013* |grep -v INCE|cut -f32 -d"," | sort -u | grep -f - BW*2013*

But the reference to the pattern will be lost. Slightly better might be
Code:
grep "ACCOUNT NOT FOUND" BW-CDR-2013* |grep -v INCE|cut -f32 -d"," | sort -u | while read P; do echo "$P"; grep -ch "$P" BW*2013*;  done

Experiment with grep's options to adapt to your needs...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get specific information from output

Hello community, I'm going crazy to analize an output via shell script and then get some information from it, here is the output: Slot 2 - MMU2 H, RAU2 X 15/A01 XPIC Enabled Autorestore Unknown Slot 3 - MMU2 H, RAU2 X 15/A01 XPIC ... (7 Replies)
Discussion started by: Lord Spectre
7 Replies

2. Shell Programming and Scripting

Help with specific output

hi folks, looking for a way to view a file and get the output of bold strings below? Thanks. 20-AUG-2017 16:14:59 * (CONNECT_DATA=(SID=TST)(CID=(PROGRAM=)(HOST=__jdbc__)(USER=xxxx))) * (ADDRESS=(PROTOCOL=tcp)(HOST=144.55.11.55)(PORT=50622)) * establish * TST * 0Please use CODE tags as required... (4 Replies)
Discussion started by: jaapar
4 Replies

3. Shell Programming and Scripting

Create specific output

I have a file that looks like the below and only need certain lines, but am not sure how to do that. It is basically everything from the @HD up to the @RG. Thank you :). file.txt - input @HD VN:1.4 GO:none SO:coordinate @SQ SN:chr1 LN:249250621 @SQ SN:chr2 LN:243199373... (3 Replies)
Discussion started by: cmccabe
3 Replies

4. Shell Programming and Scripting

Getting specific strings from output

so i have the following string: ... (3 Replies)
Discussion started by: SkySmart
3 Replies

5. Shell Programming and Scripting

grep the output between specific lines

Symmetrix ID : 00000001234 Host Name : myown Identifiers Found : 5000000000000000 5000000000000001 Device Cap(MB) Attr Dir:P ------ ------- ---- ---- 1234 25886 (M) 8D:1, 9D:1 0123 25886 (M) 8D:1, 9D:1 1345 25886 (M) ... (5 Replies)
Discussion started by: maddy.san
5 Replies

6. Shell Programming and Scripting

AWK specific output filename

Hi All, I'd like to create a specific output filename for AWK. The file I am processing with AWK looks like: output_081012.csv* 27*TEXT*1.0*2.0*3.0 where * is my delimeter and the first line of the file is the output filename i'd like to create is there a way to assign an awk... (10 Replies)
Discussion started by: LMSteed
10 Replies

7. Shell Programming and Scripting

Help with ksh script to display output with specific contents

This is Input - starts with Storage Group Name and ends with Shareable and the loop continues all I need is Storage group name and Alu numbers in the below output format requested. Storage Group Name: abcd Storage Group UID: 00:00:000:00:0:0:0 HBA/SP Pairs: HBA UID ... (6 Replies)
Discussion started by: maddysa
6 Replies

8. Shell Programming and Scripting

Screen Output to Specific Columns

User with moderate experience: I run a script (my addiction is KSH) that reads a file and reports certain parameters back to the user on screen and also piped to a file. The file(s) I read is/are located under different directories, and is usually called the same thing. Sometimes not. For... (3 Replies)
Discussion started by: Brusimm
3 Replies

9. Shell Programming and Scripting

Redirecting my output to a specific file

Hi guys am doing some checking inside my script and i want to redirect my output to a specific file for example checking if a move was successfully done and was writing on the screen whether the move was successful or not and now want to write same thing into a file... I am new to shell... (2 Replies)
Discussion started by: Lutchumaya
2 Replies

10. UNIX for Dummies Questions & Answers

Breaking output for specific pattern

Respected Sirs, I have a text file which is unfortunately unformatted. I have something like 191728/02/06226278 191828/02/06226279 191928/02/06226280 192028/02/06226281 192128/02/06226282 Can some one suggest me the way so that I can store 1917 28/02/06 226278 in different... (2 Replies)
Discussion started by: shoeb_syed
2 Replies
Login or Register to Ask a Question