Page 15 of 15

Re: Post your Command line tricks

Posted: Fri Jun 16, 2017 7:44 am
by wuxmedia
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.

Re: Post your Command line tricks

Posted: Sat Jun 17, 2017 10:57 pm
by z3bra
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!

Re: Post your Command line tricks

Posted: Sat Jun 17, 2017 11:11 pm
by wuxmedia
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 :)

Re: Post your Command line tricks

Posted: Fri Nov 10, 2017 11:53 am
by wuxmedia

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