Grep manipulation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep manipulation
# 1  
Old 05-31-2013
Grep manipulation

Hallo Team,

my little grep script captures patterns for the whole of April (extasc_cdr_201304*.bz2) but now i would like to capture my patterns per day from 1st April till 30th April (extasc_cdr_20130401*.bz2 till extasc_cdr_20130430*.bz2)

Here is my script below:

HTML Code:
bzgrep ',9100,\|,9101,\|,9102,\|,9103,\|,9104,\|,9105,\|,9106,\|,9150,\|,9151,\|,9152,\|,9153,\|,9200,\|,9201,\|,9202,\|,9203,\|,9300,\|,9301,\|,9302,\|,9303,\|,9304,\|,9305,\|,9400,\|,9401,\|,9510,\|,9511,' extasc_cdr_201304*.bz2 | bzgrep -v "0\.000" | cut -d"," -f14 | bzgrep '9100\|9101\|9102\|9103\|9104\|9105\|9106\|9150\|9151\|9152\|9153\|9200\|9201\|9202\|9203\|9300\|9301\|9302\|9303\|9304\|9305\|9400\|9401\|9510\|9511' | wc -l
# 2  
Old 06-05-2013
If file per day:
Code:
for f in extasc_cdr_20130401*.bz2
do
 fd=${f#extasc_cdr_}
 fd=${fd%.bs2}
 ... $f ... | echo $fd `wc -l`
done >output_file

Else:
Code:
for fd in {20130401..20130430}
do
 ... extasc_cdr_${fd}*.bz2 ... | echo $fd `wc -l`  
done >output_file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File manipulation

I am looking for the shortest / easiest solution to use either SED or AWK to swap two lines in a file, always swapping line 40 with line 41 in a given file. I have not tried anything yet, not sure what I would need to do (4 Replies)
Discussion started by: ziggy6
4 Replies

2. Shell Programming and Scripting

File Manipulation

Hi All! Please I wonder if I can have some help using awk and sed to extract some information. If I do ls -lrt in a directory, a list of files of months with their respective dates will appear, like files from january, February... etc, But if I want to list only files of 26th of June, I got... (7 Replies)
Discussion started by: fretagi
7 Replies

3. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies

4. Shell Programming and Scripting

File manipulation

Hi, I want to update the file with a value at a particular position $cat test.txt COL1=TEST COL2= COL3=AADSDFSDFDSFDFDF I want to update the file with a value for COL2. After update, the file should be like this $cat test.txt COL1=TEST COL2=1 COL3=AADSDFSDFDSFDFDF here 1... (9 Replies)
Discussion started by: vedanta
9 Replies

5. Shell Programming and Scripting

Text Manipulation Help

Hello unix.com people! How can I modify a text in format: A:B:C A:B:C A:B:C into C/A/B C/A/B C/A/B Note: Text is line by line and "C", "B", "A" fields are different each row. Thanks in advance. (7 Replies)
Discussion started by: galford
7 Replies

6. Shell Programming and Scripting

MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else

Hi Guys, I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys. MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' ` Harby. (4 Replies)
Discussion started by: hariza
4 Replies

7. Shell Programming and Scripting

String manipulation

Hi, i am just gettin exposed to UNIX. Could anyone of u help me out with dis problem..? i have a variable 'act' which has the value as follows, echo $act gives -0- -0- -----0---- 2008-06-04 -0- -0- echo "$act" | awk '{print ($act)}' gives, -0- -0- -----0---- 2008-06-04 -0- -0- I... (2 Replies)
Discussion started by: jerrynimrod
2 Replies

8. Shell Programming and Scripting

text manipulation

Hi, i have a file like this below, and it my have n no. of lines. Moderator gave me a solution with awk, but it was working only for the first 2 lines because awk has a limitation. can anyone give me the solution, thank you INPUT FILE: 1081 "WPCW 19 - CW/AM1, WPCB 40 - FAMN/CORNER, WPCB-DT1 50 -... (11 Replies)
Discussion started by: injeti
11 Replies

9. UNIX for Dummies Questions & Answers

string manipulation

Hi, I have a file with rows of text like so : E100005568374098100000015667 D100005568374032000000112682 H100005228374060800000002430 I need to grab just the last digits(bolded) of each line without the proceeding text/numbers. Thanks (5 Replies)
Discussion started by: james6
5 Replies

10. UNIX for Dummies Questions & Answers

manipulation

hi, i have got a table with n number of rows and 2 columns..how can i get get 1 row at a time using any unix command without copying to any file? Thanks and Regards vivek.s (13 Replies)
Discussion started by: vivekshankar
13 Replies
Login or Register to Ask a Question