LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   grep *.tpl is not working (http://www.linuxquestions.org/questions/linux-newbie-8/grep-%2A-tpl-is-not-working-653435/)

ravipat 07-03-2008 08: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
./barcode.php

Why does it not work with extnesion tpl?

Thanks,
Ravi

PatrickNew 07-03-2008 08: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 08:57 PM

grep -rl barcode ./*php
./barcode_generator.php
./equipment_maintain_list_bar.php


grep -ril barcode *.tpl */*.tpl
grep: *.tpl: No such file or directory
images-navigation/equipment_maintain_work_order.tpl
subscriber/equipment_maintain_due_assaign_wo.tpl

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 09: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.

Dave


All times are GMT -5. The time now is 10:20 PM.