<SOLVED> just how many commands are there in linux? ls -1 /bin /sbin /usr/bin | nl???

smooth_buddha

Active Member
Joined
Feb 13, 2020
Messages
362
Reaction score
246
Credits
1,648
hey guys i was playing and practicing with some piping and commands and was trying to come up with a way to count the amount of commands on my system.
I came up with this

ls -1 /bin /sbin /usr/bin | nl

so this does a listing on seperate lines of/bin /sbin and u/usr/bin and used number line and it came back with 2435

Im still trying to get my bearing of the system and i realise ive probably missed some directories and maybe not used the most effeicnt commands to get this task done. I realise i could of also used "wc" word count command piped instead of nl . would be interested to know how some of you guys would go about counting every command on the system and how to go about it
 


Code:
echo "$PATH:/bin:/sbin:/usr/bin" | tr ':' '\n' | sort -u | while read dir
do
   [[ -d "$dir" ]] && {
      find "$dir/" -type f -executable 2>/dev/null
   }
done | nl
 
Last edited:
Code:
echo "$PATH:/bin:/sbin:/usr/bin" | tr ':' '\n' | uniq | while read dir
do
   [[ -d "$dir" ]] && {
      find "$dir/" -type f -executable 2>/dev/null
   }
done | nl
You're a man of few words .. lol. Your only reply is the code to fix the OPs question.. welcome to Linux.org
 

Members online


Top