Jan 20, 2003 #1 fireant Technical User Aug 12, 2001 28 PH How do I use ls to exclude subdirectories, the . and .. but include all other files? I'll then just wc -w to get the total count of files? TIA, Louie C.
How do I use ls to exclude subdirectories, the . and .. but include all other files? I'll then just wc -w to get the total count of files? TIA, Louie C.
Jan 20, 2003 #2 marsd IS-IT--Management Apr 25, 2001 2,218 US This is one way: for i in $(ls *) do if [ -f $i ] ; then echo $i fi done man find, for another. Good Luck. Upvote 0 Downvote
This is one way: for i in $(ls *) do if [ -f $i ] ; then echo $i fi done man find, for another. Good Luck.
Jan 20, 2003 #3 predamarcel IS-IT--Management Jan 6, 2003 268 RO ls -l | grep -v ^d will give you the files + a line like `total nnnn` echo $[`ls -l | grep -v ^d | wc -l` -1] will give you the number of files in current directory. PM __ http://marcell.hypermart.net/___ Upvote 0 Downvote
ls -l | grep -v ^d will give you the files + a line like `total nnnn` echo $[`ls -l | grep -v ^d | wc -l` -1] will give you the number of files in current directory. PM __ http://marcell.hypermart.net/___
Jan 21, 2003 #4 hvn IS-IT--Management Jul 4, 2002 15 ZA using ls with the -A option will leave out the . and .. listing. eg. ls -lA should only list files with their details Upvote 0 Downvote
using ls with the -A option will leave out the . and .. listing. eg. ls -lA should only list files with their details
Jan 21, 2003 Thread starter #5 fireant Technical User Aug 12, 2001 28 PH Thanks for the reply guys. However, I found predamarcel's to be most helpful. I'd like to follow up predamarcel on a few things. How does the caret work generally? I understood the reverse matching on grep but not the caret (^). And what's the -1 at the end of the command for? Hope you don't mind. =) Thanks a lot everyone! Louie C. Upvote 0 Downvote
Thanks for the reply guys. However, I found predamarcel's to be most helpful. I'd like to follow up predamarcel on a few things. How does the caret work generally? I understood the reverse matching on grep but not the caret (^). And what's the -1 at the end of the command for? Hope you don't mind. =) Thanks a lot everyone! Louie C.