Sometimes terminal runs commands when pasted, sometimes not.

I think knowing that extra white space triggers is enough, I've tested it so much that I'm sure that this is what causes it, and thanks to KGIII again for helping me to come to this conclusion.

I still have a glass keyboard that behaves like a smart phone, and I stopped using it because it accidentally triggers things so easily, in terms of stuff getting entered that you didn't ask for...it scared me, that can destroy your system and lose your data! :oops:
I'd have sold that keyboard by now, lol. I have big hands and they don't agree with touch screens. That's why I miss my Nokia E5; it was like a Blackberry, but better. I hate today's phones.
Another tip when you copy/paste into a terminal is type out a # first before you paste .. then, after pasting if it looks good, ctrl-a to get to the beginning of the line and delete it.

I'll normally have another terminal open and just paste whatever it is into an empty file first, read through it, then paste in a terminal.
Ctrl+a. Wow, I feel like I should know that! Well, never to old to learn.
 


Ctrl+a. Wow, I feel like I should know that! Well, never to old to learn.

While we're here, insert a space at the start of the command if you don't want it being stored in your history. If it's a commonly used line, one I'll never use again, or one to test something for support reasons, I insert a space at the start of the line so that I don't clutter up my .bash_history.
 
Another tip when you copy/paste into a terminal is type out a # first before you paste .. then, after pasting if it looks good, ctrl-a to get to the beginning of the line and delete it.

I'll normally have another terminal open and just paste whatever it is into an empty file first, read through it, then paste in a terminal.
somehow this isn't working, i'm using slow coder's modification of my command in this thread, something about the way the command is listed causes the un-solicited executions plus a total of 3 empty executions that you would get from pressing enter without typing anything:

Code:
ls | sed 's/ /\\ /g' | xargs stat -c '%a %n'

i even made sure to copy and paste without selecting any whitespace. I guess the safest thing to, when copying/pasting code from the web, is to paste it to a text editor, and then copy that. I just did that with this and it's not doing anything weird.
 
While we're here, insert a space at the start of the command if you don't want it being stored in your history. If it's a commonly used line, one I'll never use again, or one to test something for support reasons, I insert a space at the start of the line so that I don't clutter up my .bash_history.
That is so super useful! Especially since I'm a person who uses the history as a way to quickly execute lengthy commands (like ffmpeg). Can't believe I didn't know that one either. Starting to think there's a whole dark web of tricks/-fu here.
 

Staff online


Top