fcjefa
Last Updated: February 25, 2016
·
1.575K
· lifeinchords

copying and pasting commands into Terminal, Linux/OSX/etc

When reading tutorials, or other sources, whether PDF or online, when coming across critical commands, you might not want to copy and paste the example you are reading directly into terminal, with the intent of modifying it and then running it.

Often, a newline character is embedded in the copy, (but may not visually appear as so), in which case, as soon as you paste into terminal, your command will be executed!

Not so bad on say, an ls, but very bad on something like this:

sudo dd bs=1m if=~/2012-09-18-wheezy-raspbian.img of=/dev/rdisk3

Here, I am about to copy and write an image to an SD card for a linux installation. The example uses the disk "/dev/rdisk3"

If I had multiple drives on my computer, and planned on updating the disk to copy to, I may have really screwed myself by pasting, before editing the command...

moral of the story: modify in notepad, then paste. Or just type nice n slow.

3 Responses
Add your response

4996

In Bash ctrl+x+e opens default editor (like vim) where you can prepare your command before executing.

over 1 year ago ·
5027

moral of the story: modify in notepad, then paste. Or just type nice n slow.

I've learned that one the hard way

over 1 year ago ·
5029

thanks Kreft .. Barnett, sorry to hear :(

over 1 year ago ·