I want to print the filename
keyword="XXTNL_AVSKRIV2ING"
ftype="sql'
I wan to search the keyword in all the sql files and the output shoul dbe filename:count
grep -iwc "$keyword" *.$ftype | grep -v ":0$"
But the output does not dispaly the filename which contains space as below.
Samlefakering v 13.6.08.sql
So i was trying to modify the command as below , but it is not working.
grep -iwc "$keyword" ?+[. ]*.$ftype | grep -v ":0$"
RudiC
July 1, 2013, 4:26am
2
What is not working? Are you sure to present the correct files to grep? Are you sure the contain your keyword? Why don't you post meaningful error msgs?
The error im getting is as below.
bash-3.00$ keyword="XXTNL_AVSKRIV2ING"
bash-3.00$ ftype="wft"
bash-3.00$ grep -iwc "$keyword" ?+[. ].$ftype | grep -v ":0$"
grep: can't open ?+[.
grep: can't open ] .wft
bash-3.00$
RudiC
July 1, 2013, 4:36am
4
Don't forget that we are dealing with shell's pattern matching, not regex matching as used in sed, awk, etc. Why wouldn't your first code work?
ftype="sql"
keyword="XXTNL_AVSKRIV2ING"
grep -iwc "$keyword" *.$ftype
Samlefakering v 13.6.08.sql:0
Samlefakering v 23.6.08.sql:0
yeah..it seems there is problem in the other part of the code where i am extarcting the basename...i will correct that..Thank you for pointing this.