Post your *nix trix...

Soldato
Joined
8 Mar 2006
Posts
13,300
Location
Near Winchester
While I consider myself a GNU/Linux guru, I still learn new things all the time. This is a thread where I'd like you all to post a nifty command/technique you've picked up. Not how to get nVidia dual screen to work, but something small that you use often. There's only one rule; no more than one line of code per post.

I'll start us off:

mv supports embedded substitution, this can be useful when renaming a file:
Code:
mv /any/old/file{,.backup}
The substitution is inside the curly braces, replace the bit before the comma (nothing) with the bit after the comma (".backup"). This also works with cp.
 
Last edited:
I used it to enforce Chrome to start on my second screen which was seemingly impossible otherwise :D

Another no less correct method is to use the compiz "place window" plugin.





grep can show you lines after and before the matching lines:
Code:
user@hostname ~ $ grep -B1 -A2 sometext /any/old/file
hello bob
have you seen sometext anywhere
yes
I have
 
Last edited:
gotta have the hammer to crack a nut:

Separate a column in a commands output by piping it into awk:
Code:
tail /var/log/messages | awk '{print $2}'
The delimiter between the columns is whitespace, but you can set it to anything with the -F parameter on awk.

sed can do this too, but I like awk.
 
Back
Top Bottom