Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Pipe that grep' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Pipe that grep
Authored by: bq on Dec 16, '02 03:01:19PM

You can also identify specific files, kinds of files, or files with specific content and then pipe data into BBEdit. For example, in tcsh:

ls -lF | bbedit

...will produce a detailed listing of directory contents in BBEdit. More interesting is to use grep to filter the results.

ls -lF | egrep '\\.gif|\\.jpg|\\.jpeg' | bbedit

...will show only files that contain those extentions.

To see only files while excluding directories from the list, do...

ls -F | grep -v '/' | bbedit

You can also list all files in the current folder or lower which contain a specific content. This one's handy: it can hit data in text files, but also Word, Excel, Powerpoint, even Illustrator files. For example, to list all files which contain the phrase "My god, it's full of stars," do

grep -rl "My god, it's full of stars" ./ | bbedit

For the brave of heart, if you want a list of all the "pages" contained in your local web server, you could do...

ls -R /Library/WebServer/Documents/ | egrep '\\./|\\.htm|\\.shtml|\\.php' | bbedit


bq



[ Reply to This | # ]