==>> What are the most useful Unix shell "one-liners" that you use? <<==

Here are a couple of mine to get the conversation started:

1. Repeat the previous command with a substring replacement:




You entered:

git clonr https://unbelievablylongurl.org/projectdirectory/evenmoreprojects/project.git

Use this:


And your command will be re-run with the replaced substring:

git clone http://unbelievablylongurl.org/projectdirectory/evenmoreprojects/project.git

2. Repeat the previous command with an additional string/character

Shell Idiom:



You ran a command that requires superuser privileges on your box. Re-run the command without retyping it like this:

sudo !!
  • You're about four years late to this... Welcome to the site. I would encourage you to ask about 10 very specific questions with a problem you are trying to solve before attempting a "survey question". The community is peculiar about which they embrace and which they extinguish with great rapidity even where there isn't a duplicate.
    – bmike
    Commented Nov 16, 2013 at 19:08
  • I have unprotected the linked question so you can add your examples here as answers if they aren't already covered.
    – bmike
    Commented Nov 16, 2013 at 19:10
  • Excellent, thank much for your responses. My apologies for the duplication of the previous question. I read through the responses to the question there and it seemed that there were a combination of shell scripts, functions, variables, bash settings, etc. I was hoping to have a bit more targeted conversation about useful, elegant single line shell commands. Will add these to that thread. Best, -C Commented Nov 16, 2013 at 19:24
  • If there's a different problem, go ahead and edit this to make it clear what problem is being solved here (as opposed to a "greatest hits") and we can look at reopening it. No worries - closing is just a temporary chance to edit and reopen if there is a better way to phrase this.
    – bmike
    Commented Nov 17, 2013 at 0:26
  • Thanks Mike. I appreciate your help. Will gain some street cred and then may try to broach this topic again. Commented Nov 17, 2013 at 0:54


Browse other questions tagged .