LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-20-2016, 10:16 PM   #1
Seattlesweet
LQ Newbie
 
Registered: May 2016
Posts: 5

Rep: Reputation: Disabled
Question Command Help


Is there a command to count how many commands you can run in bash shell?
Also is there a command to that would search all commands starting with a letter that could be run in bash shell?

Totally new to this, and not finding luck anywhere.

Thank you!
 
Old 05-20-2016, 10:33 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,317
Blog Entries: 28

Rep: Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140
The closest thing I can think of is

Code:
$ history
It will not provide the total number of commands, but it will list however many commands your BASH shell is configured to remember.

This link should help: https://sanctum.geek.nz/arabesque/better-bash-history/

Last edited by frankbell; 05-20-2016 at 10:34 PM.
 
1 members found this post helpful.
Old 05-20-2016, 11:17 PM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,305
Blog Entries: 3

Rep: Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720
If you are running bash you can use tab-completion to see what programs are available to you. So to see all programs that start with 'a' which you might run, press 'a' then tab twice. If you have a lot, then the shell will prompt you before continuing to show you all of them.

If you just want a catalog of everything available, then you can connect several programs with a pipe.

Code:
apropos -w '*' | awk '$2 == "(1)" || $2== "(8)"' | sort -u | less
Try them separately first.

Code:
apropos -w '*' 

apropos -w '*' | awk '$2 == "(1)"'

apropos -w '*' | awk '$2 == "(8)"'

apropos -w '*' | awk '$2 == "(1)" || $2== "(8)"'

apropos -w '*' | awk '$2 == "(1)" || $2== "(8)"' | sort -u

apropos -w '*' | awk '$2 == "(1)" || $2== "(8)"' | sort -u | less
That is the power of a pipe. And of course you could save the list to a file with a redirect.

Code:
apropos -w '*' | awk '$2 == "(1)" || $2== "(8)"' | sort -u > inventory.txt
Then you have a reference to format and print out or just look through. It won't tell you all the options. You'll have to run each program individually with the -h option for that, or else use the 'man' utility to see the manual page. Some programs have excellent manual pages, others are quite poor. It varies quite a bit but by and large they are useful references, but not tutorials.

From that I think you can guess how to add 'wc' to that and which option in 'wc' will give you a line count.

Last edited by Turbocapitalist; 05-20-2016 at 11:18 PM.
 
1 members found this post helpful.
Old 05-20-2016, 11:24 PM   #4
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
Blog Entries: 2

Rep: Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567
Quote:
Originally Posted by Seattlesweet View Post
Is there a command to count how many commands you can run in bash shell? ...
Maybe if you set something up to recored this ahead of time?
 
Old 05-20-2016, 11:28 PM   #5
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
Blog Entries: 2

Rep: Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567
Or maybe, wipe out:
Code:
HISTCONTROL=ignoreboth
in ~/.bashrc
 
Old 05-21-2016, 05:31 PM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
i like to use this one:
Code:
alias hf='history|grep'
but tab completion in itself is pretty effing good, also applies to directories and files (try e.g. "cat <tab><tab>" or "ls <tab><tab>").
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] [SOLVED] bash script: can echo command, command works if I type, but command doesn't work in script ... why? hopeless_n00b Linux - Newbie 10 07-12-2018 05:57 AM
LXer: How to access Linux command cheat sheets from the command line LXer Syndicated Linux News 0 07-28-2014 08:30 AM
Command/Script required to send an email alert in case command will not respond rajaniyer123 Linux - General 1 05-19-2012 01:12 PM
Executing shell command from JSP file with command line arg from URL orcusomega Programming 2 01-13-2012 03:38 PM
Bash Command Line Editor, while typing run another command before executing current? gumaheru Linux - General 5 04-13-2010 11:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration