-   Linux - Newbie (
-   -   grep *.tpl is not working (

ravipat 07-03-2008 07:31 PM

grep *.tpl is not working
Linux version: Slackware 11.0.0

grep -rl bar ./*tpl
grep: ./*tpl: No such file or directory

But with
grep -rl bar ./*php

Why does it not work with extnesion tpl?


PatrickNew 07-03-2008 07:46 PM

This is because there are no files with a tpl ending in the current directory. The * doesn't get expanded by grep, it gets expanded by the shell before grep ever sees it.

ravipat 07-03-2008 07:57 PM

grep -rl barcode ./*php

grep -ril barcode *.tpl */*.tpl
grep: *.tpl: No such file or directory

But with grep -rl barcode ./*tpl
It does not return any file though there is file with string barcode "equipment_maintain_due_assaign_wo.tpl"

david1941 07-03-2008 08:18 PM

grep lists lines in file(s) that partially match a pattern. The -l option lists the file name that does include a line that matches the pattern. If one is trying to list filenames that have a pattern one needs to generate a a list of filenames to match against. Try:
$ ls *.tpl | grep barcode
In other words: grep searches in the selected files, not the filenames.


All times are GMT -5. The time now is 12:26 AM.