doubt in grep


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting doubt in grep
# 1  
Old 04-29-2010
doubt in grep

Hi
I need to grep a particular world like and redirect into a temporary file .But while iam grepping some unwanted data are aslo coming like .ex In a FILE all these TABLENAMES are present .
module_table1,module_table2, module_table3,module_table5, module_table1_temp , module_table2_temp .....modtype_table1 ...

My requirement is to find all the table which start with a particular module and it shouldnot END WITH _temp ? Please help me .

currently i am doing like .
grep "module_*" FILE

This shows module_table1_temp , module_table2_temp also ...
But i dont need this _temp how to eliminate ?
Please help ?
# 2  
Old 04-29-2010
what about this ?

Code:
grep "module_*" FILE | grep -v "_temp"

# 3  
Old 04-29-2010
Thanks its working .Smilie
# 4  
Old 04-29-2010
Hi,

Could you post your input file ?
Fileds are seperated by comma (,) or new line ?
# 5  
Old 04-29-2010
Hi
In the files these table names are wriiten all in a new line. Can u give the input how will it act in either way if they were seperated by (,) .As for newline its working with grep "module_*" FILE | grep -v "_temp"
# 6  
Old 04-29-2010
Hi,
Code:
#!/usr/bin/perl

while (<>) {
chomp;
@array= split /\,/ ;
@modulearray= grep (/^module/,@array);
@greparray = grep (/[^temp]$/,@modulearray);
print "@greparray\n";
}

Input file
Code:
module_table1,module_table2,module_table3,module_table5,module_table1_temp,module_table2_temp,modtype_table1

Code:
Perl scriptname.pl inputfile

# 7  
Old 04-29-2010
hey it's in perl . perl i dont know Smilieanyway thanks for the effort ...hope this may help someone ..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep command doubt

Hi all, I need to find the line by using grep command with the two occurence of word in the same line. I tried the below example it prints the word choice. cat nohup.out Dictionary utl is completed. file is completed. Dictionary file is completed. grep 'Dictionary\|file'... (0 Replies)
Discussion started by: arun888
0 Replies

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

3. Red Hat

Doubt

How to create a file with specific size in RHEL6 (1 Reply)
Discussion started by: Sashi Kanth A
1 Replies

4. UNIX for Dummies Questions & Answers

Doubt

Hi , Struck with one basic question. Iam expecting word count of 4 where "wc" is showing as 5 . # echo "abcd" | wc 1 1 5 # echo abcd | wc 1 1 5 (5 Replies)
Discussion started by: penchal_boddu
5 Replies

5. UNIX for Advanced & Expert Users

doubt in df -h

in my parition i hav parition like this Filesystem Size Used Avail Use% Mounted on /dev/sda2 24G 22G 756M 97% / /dev/sda5 248G 1.2G 234G 1% /else /dev/sda1 965M 24M 892M 3% /boot tmpfs 7.0G 0 7.0G 0%... (1 Reply)
Discussion started by: ponmuthu
1 Replies

6. Shell Programming and Scripting

doubt regardin regex in grep

shudnt this command : grep test give all the lines which do not hv 'C'. ^ wrks as negating character inside square brackets right ??? bt in my case grep is printin all the line in the file also wht does grep c+ test & grep c? test shud do ??? (4 Replies)
Discussion started by: evergreen_cool
4 Replies

7. Shell Programming and Scripting

doubt in grep command

Hello i am new shell scripting. I have a file like this, $ cat myfile ;/abc/abc.cpp@@/main/1;xyz ;/abc/abc.cpp@@/main/2;usr2 ;/abc/abc.cpp@@/main/1;abc ;/abc/abc.cpp@@/main/2;usr2 ;/abc/abc.cpp@@/main/1;usr1 when i grep the file. $ grep "abc" myfile... (8 Replies)
Discussion started by: tsaravanan
8 Replies

8. UNIX for Dummies Questions & Answers

Grep doubt

Hi, I have one txt file as bellow: Inspector logging xxxxx xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxx Inspector logging xxxxxxxxxxxxxx xxxxxxxxx xxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxx Inspector loggingxxxxxxxxxxxxxxx Inspector logging xxxxx xxxxxxxxxxxxxxxxxxxxxxxx I want... (1 Reply)
Discussion started by: redlotus72
1 Replies
Login or Register to Ask a Question