Hello Vijay, On Sat 01/08/2015 14:09, Vijay Sankar wrote: [...] > To quickly see how many files I have in a directory, I use > > alias nof='ls -l . | egrep -c '^-'' > > I have always wondered if there is a better way of doing this.
In general, I would avoid using a pipe when a native command exists (and particularly in this case, where grep string comparison is a slow operation); this could probably be more appropriate: alias nof='find ./ -type f -maxdepth 1 | wc -l' See the difference in runtime in case of a huge file listing (not so uncommon...): just22@poseidon:[tmp]> time find ./ -type f -maxdepth 1 | wc -l 113069 real 0m1.732s user 0m0.100s sys 0m1.560s just22@poseidon:[tmp]> time ls -l ./ | egrep -c "^-" 113069 real 0m2.238s user 0m0.630s sys 0m1.550s All the best -- Alessandro DE LAURENZIS [mailto:just22....@gmail.com] LinkedIn: http://it.linkedin.com/in/delaurenzis