Name: Anonymous 2009-04-12 14:42
I want to make a command that will cd then ls if the dir contents will fit in one terminal line and if not will display number of items in dir how do I do that.
.bashrc:if [[ `$(echo ls who | tr howsingle 'fr\-'multr) $()./*''` == "\n" ]] ; then echo `ls -sx1a | wc -l` items ; else ls ; fi"\n" (newline) in the output of ls (broken into an array of single lines for faster execution) is met, ls feeds it output to wc (word count). Else it just does a simple ls (file listing).ls like I do, or you may use it as a callable script. In the latter case add #!/bin/bash in the beginning and $1 before both ls's that come after then.