Login Register


Neat terminal trick filter_list
Author
Message
Neat terminal trick #1
I find myself copy-pasting from my terminals (in both Windows and Linux) fairly often, whether to google errors or grab some sample output from a program. I also often find myself screwing this up and missing a few characters or performing the wrong action (i.e., hitting Ctrl+C on Linux because I'm used to Cygwin), but no more!

On windows, piping a command's output the the "clip" command will copy both standard output and standard error streams to your clipboard, and the same goes on linux with the "xclip" command, provided you have the X11 GUI installed somewhere (fun fact: also works over SSH).

Example:
Code:
; Windows > echo some text and stuff|clip # Linux $ cat some.file|xclip
(This post was last modified: 12-08-2016, 05:05 AM by Inori.)
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply

RE: Neat terminal trick #2
Wew that's pretty cool. Had to install xclip but that 'aight pretty sick. Had to make this change to make it work on my system and then made a command for it.
Code:
echo hello | xclip -selection clipboard -i

On the topic of neat terminal tricks, !! re uses the last command entered in bash. Very use full if you forget to sudo something
Code:
[lain@navi:~]$ gparted Root privileges are required for running gparted. [lain@navi:~]$ sudo !! sudo gparted We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things:    #1) Respect the privacy of others.    #2) Think before you type.    #3) With great power comes great responsibility. [sudo] password for lain:

It's all simple stuff but if you don't know it, and then you do it makes things much better!
(This post was last modified: 12-08-2016, 01:43 AM by Panther_.)
[Image: twvnig.gif]

[+] 1 user Likes Panther_'s post
Reply

RE: Neat terminal trick #3
You definitely have them reversed. cat is Linux, not Windows, and you would normally use echo on Windows...

This is a well known "trick" in batch scripting too..
- mostly braindead monkeys on this forum.

[+] 1 user Likes bitm0de's post
Reply

RE: Neat terminal trick #4
Wow. I'm surprised I never came across this! Thanks man; it's much appreciated.
Scientia potentia est

[Image: inkexplosion.jpg]

Reply

RE: Neat terminal trick #5
(12-08-2016, 01:42 AM)bitm0de Wrote: You definitely have them reversed. cat is Linux, not Windows, and you would normally use echo on Windows...

This is a well known "trick" in batch scripting too..

Seriously? Huh, I thought cat was a Windows thing as well. Guess I've been using Cygwin too much. Either way, the syntax what I was trying to demonstrate.

Fixing post.
(This post was last modified: 12-08-2016, 05:05 AM by Inori.)
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply

RE: Neat terminal trick #6
Doesn't work on XP
Code:
C:\Documents and Settings\User>echo a | clip 'clip' is not recognized as an internal or external command, operable program or batch file.

Reply

RE: Neat terminal trick #7
Thank you for this neat terminal trick.

Reply

RE: Neat terminal trick #8
(12-08-2016, 04:07 PM)Pikami Wrote: Doesn't work on XP
Code:
C:\Documents and Settings\User>echo a | clip 'clip' is not recognized as an internal or external command, operable program or batch file.

Lots of batch scripting stuff at a core level was changed from > XP, in addition to the utility programs available for use.
- mostly braindead monkeys on this forum.

Reply

RE: Neat terminal trick #9
(12-08-2016, 04:07 PM)Pikami Wrote: Doesn't work on XP
Code:
C:\Documents and Settings\User>echo a | clip 'clip' is not recognized as an internal or external command, operable program or batch file.

As @bitm0de said, Batch core and out of the box utilities have changed drastically since XP. On that note, XP support was discontinued over two years ago, so no wonder it's not up to snuff Tongue
(This post was last modified: 12-08-2016, 09:16 PM by Inori.)
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply

RE: Neat terminal trick #10
(12-08-2016, 09:16 PM)Inori Wrote:
(12-08-2016, 04:07 PM)Pikami Wrote: Doesn't work on XP
Code:
C:\Documents and Settings\User>echo a | clip 'clip' is not recognized as an internal or external command, operable program or batch file.

As @bitm0de said, Batch core and out of the box utilities have changed drastically since XP. On that note, XP support was discontinued over two years ago, so no wonder it's not up to snuff Tongue

Yeah but they added support for XP in powershell and it runs perfectly

Reply







Users browsing this thread: 1 Guest(s)