A handy tip for entering long and/or complicated commands at the Linux command prompt (when using the bash shell) from a Mastodon user

Saw this tip on Mastodon from user Stephan (@durchaus@mastodon.social) and thought it worth passing along:

When you are about to write a long and complicated command in bash, then hit CTRL+x CTRL+e to enter an editor window in which you can write the command with your default editor. The command will be executed immediately after the file is saved and the editor is closed.

(Link to post)

I never knew you could do this. And it was only a year or two ago that I found about about CTRL+r which lets you do a text search for commands in your history (so you don’t need to keep pressing the up arrow). Then again I am not a big command line user, but when I do need to use it, tips like these can be quite helpful IF I can remember them when I need them!

Thanks to Stephan for sharing this tip!

Doing Date Math on the Command Line, Parts I & II | Linux Journal

If you’ve ever used a spreadsheet, you’ve probably used or seen functions for doing date math—in other words, taking one date and adding some number of days or months to it to get a new date, or taking two dates and finding the number days between them. The same thing can be done from the command line using the lowly date command, possibly with a little help from Bash’s arithmetic.

Source: Doing Date Math on the Command Line, Part I | Linux Journal

Source: Doing Date Math on the Command Line – Part II | Linux Journal

Link: Explain Shell breaks down Linux command line arguments for you

Explain Shell is a free online service that will break down command line arguments that you enter for you. If you do not know what the commands find . -type f -print0, tar xzvf archive.tar.gz or iptables -A INPUT -i eth0 -s ip-to-block -j DROP do, you can find out now using the service.

Full article here:
Explain Shell breaks down Linux command line arguments for you (gHacks)

Link: 25+ Awesome Linux/Unix command chaining examples

Today we will learn how to use different command chaining operators available for us in an easy way.

Command chaining operators

& –Sends process background (so we can run multiple process parallel)
; –Run multiple commands in one run, sequentially.
\ –To type larger command in multiple lines
&& –Logical AND operator
|| –Logical OR operator
! -NOT operator …
| — PIPE operator
{} –Command combination operator.
() –Precedence operator

Full article here:
25+ Awesome Linux/Unix command chaining examples (The Linux Juggernaut)

Link: Our Favourite Linux Cheat Sheets

Most Linux system administrators spend their days at the command line, configuring and monitoring their servers through an SSH session. The command line is extremely powerful, but it can be difficult to keep all the options switches and tools in your head. Man pages are only a command away, but they’re often not written for quick consultation, so when we’re stuck for some of the more arcane options, we reach for the collection of cheat sheets that we’ve curated over the years.

Even command line masters occasionally need a litte help, and we hope that terminal beginners will find these concise lists useful too. All of these tools are installed by default on a standard Linux box except for Vim and Emacs, which may or may not be available (see the package manager cheat sheets for how to get them).

Full article here:
Our Favourite Linux Cheat Sheets (Everyday Linux User)

Article series: CommandLineFu, BASH, AWK, Perl, SED One-Liners Explained

We must confess that we are not as fond of the Linux command line as some Linux users — we’ll take a good GUI, and a mouse over a keyboard any time we can. But for those that love working at the Linux command prompt (and that probably don’t make nearly as many typos as we do), we thought you might appreciate this series from the catonmat blog:

Or perhaps you’d prefer this series:

Or maybe you’d like to see one-liners covering Awk, Sed, or Perl:

 

 

Author Peteris Krumins used these articles as the starting points for his e-books. In addition to the e-books listed there, it appears that he has authored this paperback edition that can be purchased from Amazon (this is an affiliate link, so if you buy it from here we’ll get a small commission):

Perl One-Liners: 130 Programs That Get Things Done