LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 11: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, 11:33 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mageia, and whatever VMs I happen to be playing with
Posts: 11,680
Blog Entries: 12

Rep: Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902Reputation: 2902
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 11:34 PM.
 
1 members found this post helpful.
Old 05-21-2016, 12:17 AM   #3
Turbocapitalist
Senior Member
 
Registered: Apr 2005
Distribution: Ubuntu, Devuan, OpenBSD
Posts: 1,387
Blog Entries: 3

Rep: Reputation: 567Reputation: 567Reputation: 567Reputation: 567Reputation: 567Reputation: 567
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-21-2016 at 12:18 AM.
 
1 members found this post helpful.
Old 05-21-2016, 12:24 AM   #4
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US, Earth, end border$! ◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that works well on my cheapest; has been KDE or CLI but open... http://goo.gl/NqgqJx &c ;-)
Posts: 3,288
Blog Entries: 2

Rep: Reputation: 939Reputation: 939Reputation: 939Reputation: 939Reputation: 939Reputation: 939Reputation: 939Reputation: 939
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-21-2016, 12:28 AM   #5
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US, Earth, end border$! ◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that works well on my cheapest; has been KDE or CLI but open... http://goo.gl/NqgqJx &c ;-)
Posts: 3,288
Blog Entries: 2

Rep: Reputation: 939Reputation: 939Reputation: 939Reputation: 939Reputation: 939Reputation: 939Reputation: 939Reputation: 939
Or maybe, wipe out:
Code:
HISTCONTROL=ignoreboth
in ~/.bashrc
 
Old 05-21-2016, 06:31 PM   #6
ondoho
Senior Member
 
Registered: Dec 2013
Posts: 4,620

Rep: Reputation: 984Reputation: 984Reputation: 984Reputation: 984Reputation: 984Reputation: 984Reputation: 984Reputation: 984
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 9 02-26-2016 02:11 PM
LXer: How to access Linux command cheat sheets from the command line LXer Syndicated Linux News 0 07-28-2014 09:30 AM
Command/Script required to send an email alert in case command will not respond rajaniyer123 Linux - General 1 05-19-2012 02:12 PM
Executing shell command from JSP file with command line arg from URL orcusomega Programming 2 01-13-2012 04:38 PM
Bash Command Line Editor, while typing run another command before executing current? gumaheru Linux - General 5 04-13-2010 12:21 PM


All times are GMT -5. The time now is 01:17 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration