Datamation content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.
I’ve been using bash for years, and I still haven’t come anywhere close to mastering the full range of available command line keyboard shortcuts. I’ve found the best way to get more under my fingers is to note a few on a Post-It stuck to the monitor, and then swap it for another one at intervals.
Here, are a few useful candidates.
(C = control key, M = alt/meta key.)
- C-r and C-s : Launch an incremental search backward and forward (respectively), in your command-line history.
- C-j and C-g : Abandon an incremental search either with the line
found, or with the original line (respectively).
- M-. or ESC then . : Both of these insert the final argument to the
last command at the cursor point. This is useful when moving files around and
editing them.
- M-C-y : Insert the first argument to the previous command at the
cursor point. If you want the nth argument, hit M-n beforehand. So
M-2 M-C-y would give you the 2nd argument to the previous command. (A
lot of keys to remember, but it’s useful once in a while.)
- C-w and M-backspace : Both delete the word behind the cursor. C-w
uses whitespace as a boundary, whereas M-backspace uses non-alphanumeric
characters. So if you have file.txt and hit C-w, you’ll delete
the lot, whereas M-backspace would leave you with file.. This
has very obvious uses. (It also works with underscores.)
I learned some new shortcuts while researching this, so hopefully you learned
something useful, too!
Ed Note: A quick note about the Perltidy tip from a fortnight ago. Thanks to
Randal L. Schwartz for pointing out that it’s a good idea to set up tests for your code, to check that it does the same thing after Perltidy is
finished as it did before. As he discusses here, ultimately the only thing that can interpret Perl code entirely reliably is the Perl interpreter itself. So be aware that there are circumstances in which Perltidy (and similar programs) can break code!
This article was first published on ServerWatch.com.
RELATED NEWS AND ANALYSIS
-
Ethics and Artificial Intelligence: Driving Greater Equality
FEATURE | By James Maguire,
December 16, 2020
-
AI vs. Machine Learning vs. Deep Learning
FEATURE | By Cynthia Harvey,
December 11, 2020
-
Huawei’s AI Update: Things Are Moving Faster Than We Think
FEATURE | By Rob Enderle,
December 04, 2020
-
Keeping Machine Learning Algorithms Honest in the ‘Ethics-First’ Era
ARTIFICIAL INTELLIGENCE | By Guest Author,
November 18, 2020
-
Key Trends in Chatbots and RPA
FEATURE | By Guest Author,
November 10, 2020
-
Top 10 AIOps Companies
FEATURE | By Samuel Greengard,
November 05, 2020
-
What is Text Analysis?
ARTIFICIAL INTELLIGENCE | By Guest Author,
November 02, 2020
-
How Intel’s Work With Autonomous Cars Could Redefine General Purpose AI
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
October 29, 2020
-
Dell Technologies World: Weaving Together Human And Machine Interaction For AI And Robotics
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
October 23, 2020
-
The Super Moderator, or How IBM Project Debater Could Save Social Media
FEATURE | By Rob Enderle,
October 16, 2020
-
Top 10 Chatbot Platforms
FEATURE | By Cynthia Harvey,
October 07, 2020
-
Finding a Career Path in AI
ARTIFICIAL INTELLIGENCE | By Guest Author,
October 05, 2020
-
CIOs Discuss the Promise of AI and Data Science
FEATURE | By Guest Author,
September 25, 2020
-
Microsoft Is Building An AI Product That Could Predict The Future
FEATURE | By Rob Enderle,
September 25, 2020
-
Top 10 Machine Learning Companies 2021
FEATURE | By Cynthia Harvey,
September 22, 2020
-
NVIDIA and ARM: Massively Changing The AI Landscape
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
September 18, 2020
-
Continuous Intelligence: Expert Discussion [Video and Podcast]
ARTIFICIAL INTELLIGENCE | By James Maguire,
September 14, 2020
-
Artificial Intelligence: Governance and Ethics [Video]
ARTIFICIAL INTELLIGENCE | By James Maguire,
September 13, 2020
-
IBM Watson At The US Open: Showcasing The Power Of A Mature Enterprise-Class AI
FEATURE | By Rob Enderle,
September 11, 2020
-
Artificial Intelligence: Perception vs. Reality
FEATURE | By James Maguire,
September 09, 2020