command to display all text files inside a directory

Steven W. Orr steveo at syslang.net
Mon Jun 26 13:15:00 UTC 2006


On Monday, Jun 26th 2006 at 07:42 -0500, quoth David Gomez:

=>On Mon, 2006-06-26 at 15:49 +0530, Kaushal Shriyan wrote: > Hi ALL > > 
=>which command is used to display all text files inside a particular 
=>directory >
=>
=>That depends on what do you mean by 'text files'
=>
=>I would use something like this.
=>
=>find <start_directory> -type f -exec file {} \| grep
=><some_strings_matching_text_files> \; -print

By my BEARD I wish people would stop using find -exec.

WHY in the Wide Wide World of Sports would anyone start a seperate process 
for each file encountered when they could do it all in one process.

PLEASE read the xargs manpage. Learn it. Love it.

find $dir -type f | xargs file | grep 'ASCII text' | awk '-F: {print $1}'

or if it was appropriate you might just be able to live with 

ls *.txt

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net




More information about the fedora-list mailing list