[olug] Unix Tip: USE DU TO FIND FILES

Jeff Hinrichs jeffh at delasco.com
Mon Apr 21 03:46:50 UTC 2003


David Walker said:
> the command "du -a |grep *.txt" did not work for me
> it seems to pipe the output of "du -a" into "grep *.txt"
> but "grep *.txt" will expand to
> "grep file1.txt file2.txt file3.txt" which will
> search for the string "file1.txt" in file2.txt and in file3.txt
>
> I think the desired result is achieved with
> du -a|grep "\.txt\$"
>
> If you just want the current directory you can use bash's filename
> expansion  with one of several commands
>
> echo *.txt
> ls -l *.txt
> du *.txt
+1 on ls *.txt, it's curious why anyone would use find or du for the
current directory.  Am I missing something?
-Jeff




More information about the OLUG mailing list