Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can't paste the long command into the terminal.

There is a ls command which takes alot of argumnets and i'm trying to insert in into the terminal by copying.

But it runs every single line.

So i get error.

What can i do ?

share|improve this question
What command? It would help us get more info to solve your problem – Parto Feb 16 at 14:11
Some command could be anything. Paste it here, so at least we know what we're dealing with. – Serg Feb 16 at 14:19
up vote 4 down vote accepted

It sounds like it's multiple commands, or one that has —for some reason or other— been split over multiple lines. If you could show us, that would go some distance to let is know which it is in this case.

That's not to say that there aren't cases where a command really is too long, it's just really rare in practice, certainly when copying and pasting! If you are hitting this wall, look at xargs per Eduard's answer.

If it's one command with added newlines, remove the newlines.

Formatting on the internet isn't always perfect. Some websites (and authors) use poor tags for code and that can mean that some things get split onto multiple lines, breaking them. A simple example is running ls on two directories getting truncated:

ls a_really_long_directory_name

The simple answer here is just removing that newline:

ls a_really_long_directory_name another_really_long_directory_name

But you can also escape the newline with a backslash as the last character on the line:

ls a_really_long_directory_name \

If it's multiple commands that you want to run all together, not as you paste, bung them in a script and run that when you're ready.

If "the command" actually looks like:

ls a_really_long_directory_name
ls another_really_long_directory_name

That's two commands. When you paste them in each newline character is going to force that line to run. That's how most shells work in Ubuntu. If you want to bunch them together you can paste them into a file (let's call it myscript) and then tell bash to run those commands:

bash myscript

You don't have to mess around with crunchbangs and execute permissions, you just tell bash which file to open and run. You can do those things if you want to but they aren't necessary here.

share|improve this answer
Yeah , that had some newline codes... Thanks – Arshia Aghaei Feb 16 at 15:13

The length limit is rather long, you can check it with:

xargs --show-limits

(see What is the maximum length of command line arguments in gnome-terminal?)

So there are probably new lines between the comments. You can check it by first pasting it into gedit and make sure it has only one line, then you can paste it in the terminal use Ctrl+Shift+V

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.