Post your Command line tricks

Forum rules
Share your brain ;)
User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: Post your Command line tricks

Unread post by wuxmedia » Fri Jun 16, 2017 7:44 am

had to read those code boxes several times. Still not sure what they are about but I'm sure they are cool.
nice redshift alternative, yeah it doesn't need to be a big program, what the hell has the candian tv got to do with it? needs a wrapper to vary it at diff times of day.
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
z3bra
Window Manager
Posts: 53
Joined: Fri Jun 27, 2014 8:34 am
Location: France
Contact:

Re: Post your Command line tricks

Unread post by z3bra » Sat Jun 17, 2017 10:57 pm

The first one is the vanilla way to create linux containers, so the last line is basically what happens when you use lxc-create or docker run.

The second one is more... subtle. The #include statement in C is read by the compiler at compilation time, and included in the code as if it were part of the file.
By including /dev/stdin, you get prompted to write the file to include at compile time, which means that you write the code DURING the compilation. I found that pretty cool!
BANGARANG, MOTHERFUCKER.

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: Post your Command line tricks

Unread post by wuxmedia » Sat Jun 17, 2017 11:11 pm

oh I see. This and some other things have got me doing the exercises in the C programming language book this weekend, so I do sort of get it more now :)
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: Post your Command line tricks

Unread post by wuxmedia » Fri Nov 10, 2017 11:53 am

Code: Select all

wux@dimholt:~$ xargs -I % rgrep % /etc/passwd <<<wux
wux@dimholt:~$ wux:x:1000:1000:wux,,,:/home/wux:/bin/bash
WTF is wux doing? Well, this is just an example - I had a bunch of searchterms to copy into grep, and was fed up of cursoring around and editing the line in the middle to put the new searchterm in, yeah I could have scripted it, but I think this is cool. also a search term can be piped in from a find or another grep.
My main point was to have that line, then backwards word delete then paste (with the newline so it just runs) then I'd decide what to do based on the output.
The '%' is a placeholder, for multiple use (think mv or cp) then use '{}' a bit like in the native find function.
Also at the end it uses the heredoc function of bash to make an input like it's a file, more famously known as the cat <<< text EOF thing.
I'd better actually get on and use it now (took ages to even work out how to describe it, colleagues are still not sure what i'm talking about - no change there then :)
source
"Seek, and Ye shall find"
"Github | Chooons | Site"

Post Reply