handling with grep


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting handling with grep
# 1  
Old 04-26-2012
Question handling with grep

commad is like this

Code:
cat filecount.txt | awk -F " " '{print $9}'| grep rcm*200212*

the problem is with * its not taking * for grep.

Quote:
i want list all the file with rcm*200212*
# 2  
Old 04-26-2012
grep does regular expressions, not globs. ".*" acts more like what you want -- "." means "match any single character", and * means "zero or more of the previous character". Regular expressions are also different in that they don't need to match the entire line the way globs do.

And if you're using awk, you can do it all in awk anyway.

And that's a useless use of cat.

I think this regex does what you want, but without seeing the input data I can't be positive:

Code:
awk awk -F " " '$9 ~ /^rcm.*200212/ {print $9}' filename


Last edited by Corona688; 04-26-2012 at 03:17 PM..
# 3  
Old 04-26-2012
dear Corona688

not working
# 4  
Old 04-26-2012
Try this:

Code:
awk -F " " '{print $9}'filecount.txt | grep "rcm*200212*"

# 5  
Old 04-26-2012
The above post only repeats your original problem.

Quote:
Originally Posted by sagar_1986
dear Corona688

not working
In what way is it "not working"? Without your original input data, I cannot test my answer against your data, and must make assumptions about what you have. I tried to reverse engineer your broken answer into what I thought you wanted, and being it was only a guess, guessed wrong.

Please post some of your original input so I don't need to guess.
# 6  
Old 04-26-2012
Good response Corona. I was thinking the same thing.
# 7  
Old 04-27-2012
@Corona

your awk statement has two awk

It should be one right ?

Code:
 
awk awk -F " " '$9 ~ /^rcm.*200212/ {print $9}' filename

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. UNIX for Dummies Questions & Answers

File handling

I have a file 1 298167 298168 1093209 1093210 1422663 I want to write a code where in I want to read contents of above file like first read is 1 second read is 298167 Substract second read from first and if this is greater than or less than 99,999. Similarly I want to traverse thru... (3 Replies)
Discussion started by: Guru148
3 Replies

3. Shell Programming and Scripting

Handling string

I have to source a file "varname" the content of varname file is like this: #ani ani1 = abc_ani ani2 = def_ani #sham sham1 = abc_sham sham2 = abc_sham Now i need to extract any line containing "ani: in it. And then store the extracted info in a file. (3 Replies)
Discussion started by: animesharma
3 Replies

4. Programming

Exception Handling C++

Hello All, I have a question ....which I am totally confused about! If I have a fxn foo in a program which returns a logical value. But it has a posssiblity to throw some exception. Now my exception handler returns a value as a string stating why the exception occured. But my... (1 Reply)
Discussion started by: mind@work
1 Replies

5. Shell Programming and Scripting

Handling Variables

Experts & Learned Folks, Im asking for a solution that Im not sure as how to handle. Owing to reasons of anonymity, I masked some of the text that Im searching for here. Ok. Here it goes. I have an output of script like below - THIS IS THE DATALEFT ON FIRST LINE WITH COUNT 75. THIS IS THE ... (7 Replies)
Discussion started by: ManoharMa
7 Replies

6. UNIX for Advanced & Expert Users

please help me in file handling

sir i have to get first line from a file for example >cat file1 abc zxc asd adsf from that file1 i need only first line expected result >abc please help me ! (1 Reply)
Discussion started by: ponmuthu
1 Replies

7. Shell Programming and Scripting

String handling

shell script to input two strings and stripe out the second string from the first string either from the beginning or from the end as per the user's choice (3 Replies)
Discussion started by: Priyanka Bhati
3 Replies

8. Programming

Signal Handling

Hi folks I'm trying to write a signal handler (in c on HPUX) that will catch the child process launched by execl when it's finished so that I can check a compliance file. The signal handler appears to catch the child process terminating however when the signal handler completes the parent... (3 Replies)
Discussion started by: themezzaman
3 Replies

9. Programming

File Handling in C

Hi all, I have a problem in handling files through C. here is the problem im having: i will query the database (for instance consider employees table ) for empno,ename,job,salary fields.The query returns me some 100 of rows. now i need to place them in a file in row wise pattern as they... (3 Replies)
Discussion started by: trinath
3 Replies

10. UNIX for Dummies Questions & Answers

Parameter handling

Hi, i would like to ask that: If u need to do something like this: counter = 1; so that $($counter) = $1, and when u counter++, $($counter) will become $2. How can we do this? (1 Reply)
Discussion started by: AkumaTay
1 Replies
Login or Register to Ask a Question