This question already has an answer here:

==>> 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 !!

marked as duplicate by bmike Nov 16 '13 at 19:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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 Nov 16 '13 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 Nov 16 '13 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 – Chris Simpkins Nov 16 '13 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 Nov 17 '13 at 0:26
  • Thanks Mike. I appreciate your help. Will gain some street cred and then may try to broach this topic again. – Chris Simpkins Nov 17 '13 at 0:54