This subchapter looks at command history in a UNIX (and Linux) BASH shell.
Command history is used to recall recent commands and repeat them with modifications.
You will find that you are often repeating a few common commands over and over with variations in the options and arguments (such as file names). Having the ability to recall a previous example and make a few changes will greatly save on typing.
Pushing the Up Arrow key will bring back previously typed commands one at a time (from most recently typed to the first typed).
Pushing the Down Arrow key will move from the oldest to the newest commands one at a time.
The commands brought back by the Up Arrow and Down Arrow keys will appear after the current prompt.
You can press the ENTER or RETURN key to immediately run any selected command.
After using the Up Arrow or Down Arrow keys, your cursor is at the end of the line. You can use the DELETE key to remove old arguments and then start typing in new ones.
Note that holding down the CONTROL key and pressing the p key at the same time will take you to the previous command just like the Up Arrow key. This is written ^p.
Holding down the CONTROL key and pressing the n key at the same time will take you to the next command just like the Down Arrow key. This is written ^n.
Pressing the META key (or on some systems pressing the ESCAPE key), then releasing it, then typing the less than < key will take you to the beginning of the command history. Pressing the META key (or on many modern systems pressing the ESCAPE key or ESC key), then releasing it, then typing the greater than > key will also move to the end (most recent) command history. These are written M-< and M->.
editing a line
As mentioned above, when you use command history, the cursor is at the end of the recalled command.
Either the Left Arrow or ^b will go one character backward (towards the beginning of line).
Either the Right Arrow or ^f will go one character forward (towards the end of line).
Typing inside a line will place characters in front of the cursor. The character inside the cursor remains unchanged.
Using the DELETE key will delete the character in front of the cursor. The character inside the cursor remains unchanged.
^k will delete everything from the cursor to the end of the line.
^d will delete the character inside (under) the cursor.
M-b will move you one word back (towards beginning of line). In this case, a word is a collection of characters, usually separated by a space character.
M-f will move you one word forward (towards end of line).
^e will move to the end of the line and ^a will move to the beginning of the line.
Once you have edited your command, use the RETURN or ENTER key to run the new command. You can use the ENTER or RETURN key from anywhere in the command line. You do not have to be at the end of the command line.
free music player coding example
Coding example: I am making heavily documented and explained open source code for a method to play music for free almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).
Work on this project is very slow because I am homeless. I am available for work if someone can provide an indoor place to work in Costa Mesa, California, electricity, internet connections, a flat raised working surface (such as a table or desk), a sitting device (such as a chair or stool), and a fully functional reasonably modern used computer. Im already homeless, so you dont need to pay me (and I understand how much business people hate the minimum wage law). Just give me a chance to work.
Building a free downloadable text book on computer programming for university, college, community college, and high school classes in computer programming.
If you like the idea of this project, then please donate some money.
send donations to: Milo
PO Box 1361
Tustin, California 92781
At the time I am homeless. This greatly interferes with my ability to create this project, which can help nearly 20 million U.S. college students and more than 150 million students world-wide. I am looking for 30 rich people or corporations willing to donate $10 a month to my church so that the church can provide a place indoors for me to continue work. If you want to donate, please see help project. Thanks much.
Supporting the entire project:
If you have a business or organization that can support the entire cost of this project, please contact Pr Ntr Kmt (my church)
UNIX used as a generic term unless specifically used as a trademark (such as in the phrase UNIX certified). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.
Names and logos of various OSs are trademarks of their respective owners.