Egrep question


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Egrep question
# 1  
Old 07-08-2008
Computer Egrep question

I have a script that does the following. It searches a listing of directories with specific extensions and then formats a wc on those files. The code looks like this

Code:
find <directory>  -name '*.js' -o -name '*.html' | awk '{print \"wc -l \"$1}' > file \n"

The result is a file with the "wc -l" command preceeding the file directory listing ---> wc -l <file directory listing>

Is there a way to do the same thing but use
Code:
 | awk '{print \"egrep -cv ^$|^[/]\$1'}

Using egrep at the CLI helps to eliminate the blanks and commented code. I just can't seem to get it to work in the script. Thanks in advance
# 2  
Old 07-08-2008
Do you mean something like this?

Code:
... | awk '{print "egrep -cv \^$|\^[/]\\" $1}'

Regards
# 3  
Old 07-08-2008
Quote:
Originally Posted by Franklin52
Do you mean something like this?

Code:
... | awk '{print "egrep -cv \^$|\^[/]\\" $1}'

Regards
Something like that but I am still getting a syntax error.
# 4  
Old 07-09-2008
Give some lines of the input and the desired output of the awk command.
# 5  
Old 07-09-2008
The script I was given is an AWK script and It has alot of output string commands. This AWK script creates a .sh script with all the listing and various functions. Once, the AWK script is complete, the .sh script runs. The first piece of code, finds all the files of a particular type and then that output is piped to an AWK statement that prints the letters 'wc -l' proceeding each listed directory file (the listings are in a .sh file).

There is alot to post but I just want to get the correct expression to accurately capture lines of code by omitting blank lines and comments. Egrep seems to do it best but I don't know how to add that to the script.
# 6  
Old 07-09-2008
You can try this with find:

Code:
find <directory>  -name '*.js' -o -name '*.html' -exec egrep <options> {} \;

# 7  
Old 07-09-2008
Quote:
Originally Posted by Franklin52
You can try this with find:

Code:
find <directory>  -name '*.js' -o -name '*.html' -exec egrep <options> {} \;

This didn't work either. I will send you a PM.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Lines of code in egrep question

Hi, I have a question, during my readings it appears that these two variables in the snippet below need to be on the same line to return a “true” answer and listed in the output otherwise it won’t be returned. How can I write this snippet to make it return a “true” if those two variables are on... (6 Replies)
Discussion started by: bdby
6 Replies

2. Shell Programming and Scripting

sed and egrep question

Its really 2 questions, but both are pretty basic. Linux Redhat 1. Need to do a search and replace on a file. I need to append '--' (comment out the line) to specific lines based on a wildcard search. So if I Have GRANT SOME_ROLE_OR_USER ... I dont care what comes after that.... (2 Replies)
Discussion started by: guessingo
2 Replies

3. Shell Programming and Scripting

regex question using egrep

Hi, i have a a bunch of directories that are always named with six lowercase alpha's and either one or two numeric's (but no more) so for example names could be qwerty1 qwerty9 qwerty10 qwerty67 I am currently using two pattern matches to capture these names echo $DIR |... (8 Replies)
Discussion started by: rethink
8 Replies

4. UNIX for Dummies Questions & Answers

egrep count question

Hello all, I'm a first time poster and a unix/linux noob so please be understanding. I am trying this command below: # egrep -c "Oct".+"Connect: ppp" /var/log/messages* /var/log/messages:53 /var/log/messages.1:35 /var/log/messages.2:63 /var/log/messages.3:27 /var/log/messages.4:12 ... (1 Reply)
Discussion started by: morrowtech
1 Replies

5. Shell Programming and Scripting

egrep question

I want to egrep for certain fields which are not existing in the current log files and am getting errors for that... egrep "'^20090220.14'|'^20090220.15'|'^20090220.16'|'^20090220.17'|'^20090220.18'" Some of the times are in future and logs don't have those entries and I get errors for them... (1 Reply)
Discussion started by: jacki
1 Replies

6. UNIX for Dummies Questions & Answers

search ")" with egrep - egrep: syntax error

Hi Guys, we have a shell script which basically query the Database which retrieves huge data and use the data with "egrep" . Now there is some data which contains characters like "abc)" and the same is used like below : "egrep (.+\|GDPRAB16\|GDPR/11702 96 abc)\|$ temp.txt" now while... (7 Replies)
Discussion started by: sagarjani
7 Replies

7. Shell Programming and Scripting

egrep

Hi, I don't understand what is the correct way of writing: egrep -l '{$min,$max} $pattern' $filename I tryed to search on google how to wtrite {$min, $max}, but I don't have success (7 Replies)
Discussion started by: DNAx86
7 Replies

8. UNIX for Dummies Questions & Answers

Egrep cheat sheet anywhere? Looking for meaning of egrep -c

Hi I've been searching google and have not found what egrep -c means. Does anyone know where I can get a cheat sheet or what that -c means? thanks, Linda (2 Replies)
Discussion started by: leelm
2 Replies

9. UNIX for Dummies Questions & Answers

question on egrep

Hi I am trying to use this command: egrep '^a{2,6}$' testexpr4D to retreive lines with 2,3,4,5, or 6 a's in a file . The file testexpr4D has entries like: a aa aaa aaaa aaaaa aaaaaa 123456 ABCDEF I was expecting to see 5 lines in the output but nothing happens. Can anyone help... (10 Replies)
Discussion started by: rohitv
10 Replies

10. Shell Programming and Scripting

egrep help

How can i make something like if (echo "$arg2" | egrep -s '^+\.+km/h+$|^+km/h+$'); then not to output the value of $arg2 on the screen, evertime i get match it outputs the value of the variable on the screen which i don't need to do. I know for grep its -q option but it doesn't work for egrep.... (2 Replies)
Discussion started by: Vozx
2 Replies
Login or Register to Ask a Question