Post your Command line tricks
Forum rules
Share your brain ;)
Share your brain ;)
Re: Post your Command line tricks
https://stackoverflow.com/questions/158 ... ific-cases
https://stackoverflow.com/questions/211 ... es-of-bash
https://stackoverflow.com/questions/683 ... using-bash
https://stackoverflow.com/questions/211 ... es-of-bash
https://stackoverflow.com/questions/683 ... using-bash
If you can do it go ahead and do it, if you can't do it then don't even criticize it. - gingerdesu
- kiiroitori
- dpkg-reconfigure
- Posts: 72
- Joined: Tue Aug 27, 2013 12:22 pm
Re: Post your Command line tricks
Thanks to stark I know now that Ctrl+r searches your history recursively. Yes I didn't know that! This command is the dmenu of bash! It's like realizing the sunglasses you were looking for are actually on your forehead and that they are polarized expensive cool as fuck sunglasses! Thanks stark (heart icon here)
Re: Post your Command line tricks
that's why this thread is so great. So much out there, so much to remember (which none of us can).
Work hard; Complain less
- Dr_Chroot
- Alfalfa
- Posts: 1100
- Joined: Mon Jun 09, 2014 9:49 pm
- Location: among the sagebrush
- Contact:
Re: Post your Command line tricks
Yes, it is all good stuff fo sho! Thanks stark :D (I hadn't the faintest idea about reverse searching history either.)
Fight internet censorship.
EFF | Tor Project | Bitcoin
"There have been times throughout American history where what is right is not the same as what is legal. Sometimes to do the right thing you have to break the law." - Edward Snowden
EFF | Tor Project | Bitcoin
"There have been times throughout American history where what is right is not the same as what is legal. Sometimes to do the right thing you have to break the law." - Edward Snowden
- wuxmedia
- Grasshopper
- Posts: 6454
- Joined: Wed Oct 17, 2012 11:32 am
- Location: Back in Blighty
- Contact:
Re: Post your Command line tricks
wow, yeah you guys need to go through this thread then :P
I was going to moan at simple thread postage, but that seems to have worked.
ctrl-r is massive, combine it with a '#' and a unique line you have a marker.
yes you can comment out on the cmd line.
My fav is alt dot - which is in this and one of those threads too.
All these things make the CLI a lot more friendly
I was going to moan at simple thread postage, but that seems to have worked.
ctrl-r is massive, combine it with a '#' and a unique line you have a marker.
yes you can comment out on the cmd line.
My fav is alt dot - which is in this and one of those threads too.
All these things make the CLI a lot more friendly
- kiiroitori
- dpkg-reconfigure
- Posts: 72
- Joined: Tue Aug 27, 2013 12:22 pm
Re: Post your Command line tricks
This stuff just keeps getting better. Thanks Wux!wuxmedia wrote:ctrl-r is massive, combine it with a '#' and a unique line you have a marker.
Re: Post your Command line tricks
Thanks Everyone. I'm just trying to stay away from zsh ( no offence ).
https://github.com/revans/bash-it
https://github.com/revans/bash-it
If you can do it go ahead and do it, if you can't do it then don't even criticize it. - gingerdesu
Re: Post your Command line tricks
Can I put a nano tip here? I often load a second file into vim so I can copy a snippet and paste it into the file I'm working on. nano can do this too. I've used this in the past, but so infrequently that I had to look it up every time. I think I can remember it this time.
1. If you are already running nano, turn on multibuffer mode with "alt F" -- if this is something you like and want to use all the time, put "set multibuffer" in your nanorc, or start nano with "nano --multibuffer" or "nano -F".
2. Once you are editing one file, load more files with "ctrl r"
3. To switch between the buffers, use "alt ," and "alt ."
Now you can cut lines from one file and paste them into the other.
http://www.nano-editor.org/dist/v2.2/faq.html#3.7
Finally, if you know you want two (or more) files loaded at once, use "nano <file1> <file2> ..." -- then "alt ," or "alt ." will switch between them.
Thanks to stark for reminding me to look this up and learn it again.
1. If you are already running nano, turn on multibuffer mode with "alt F" -- if this is something you like and want to use all the time, put "set multibuffer" in your nanorc, or start nano with "nano --multibuffer" or "nano -F".
2. Once you are editing one file, load more files with "ctrl r"
3. To switch between the buffers, use "alt ," and "alt ."
Now you can cut lines from one file and paste them into the other.
http://www.nano-editor.org/dist/v2.2/faq.html#3.7
Finally, if you know you want two (or more) files loaded at once, use "nano <file1> <file2> ..." -- then "alt ," or "alt ." will switch between them.
Thanks to stark for reminding me to look this up and learn it again.
- wuxmedia
- Grasshopper
- Posts: 6454
- Joined: Wed Oct 17, 2012 11:32 am
- Location: Back in Blighty
- Contact:
Re: Post your Command line tricks
^ that's handy, most of the work installs have vim as default, but some don't. so that's a great way of visually diffing files, or indeed c/p from/to files.
Again. it's nice having your own system as custom as you can make it, but that just doesn't happen in most work environments. Unless you are the CTO...
So always good to know the defaults of bash certainly.
Again. it's nice having your own system as custom as you can make it, but that just doesn't happen in most work environments. Unless you are the CTO...
So always good to know the defaults of bash certainly.
Re: Post your Command line tricks
^ "vimdiff <file1> <file2>" is still my favorite way to compare two files (like kernel configs).
Re: Post your Command line tricks
so I'm wondering now ....
vim T & T thread?
nano T & T thread?
vim T & T thread?
nano T & T thread?
Work hard; Complain less
Re: Post your Command line tricks
I am also thinking about tmux T&T ;)
Maybe "non emacs T&T?"
Maybe "non emacs T&T?"
Re: Post your Command line tricks
Good timing, I just learned one tmux trick. You can hide the status bar!
Work hard; Complain less
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Post your Command line tricks
That's super-neat, thanks for the tip. I only knew about multiple files,but not that new buffers can be created. I should RTFM more :)pidsley wrote:Can I put a nano tip here? I often load a second file into vim so I can copy a snippet and paste it into the file I'm working on. nano can do this too. I've used this in the past, but so infrequently that I had to look it up every time. I think I can remember it this time.
1. If you are already running nano, turn on multibuffer mode with "alt F" -- if this is something you like and want to use all the time, put "set multibuffer" in your nanorc, or start nano with "nano --multibuffer" or "nano -F".
2. Once you are editing one file, load more files with "ctrl r"
3. To switch between the buffers, use "alt ," and "alt ."
Now you can cut lines from one file and paste them into the other.
http://www.nano-editor.org/dist/v2.2/faq.html#3.7
Finally, if you know you want two (or more) files loaded at once, use "nano <file1> <file2> ..." -- then "alt ," or "alt ." will switch between them.
Thanks to stark for reminding me to look this up and learn it again.
..gnutella..
Re: Post your Command line tricks
A small, but cool one:
To generate an HTML page out of a markdown page, and add a header/footer meanwhile.
Code: Select all
markdown < body.md | cat header.html - footer.html > index.html
BANGARANG, MOTHERFUCKER.
- doubledutch
- killall X
- Posts: 163
- Joined: Sun Aug 10, 2014 1:25 pm
Re: Post your Command line tricks
One I had to search for last week:
Disk Usage, human readable, 3 folders deep. Feel free to change depth and directory:
Generation after generation:
ccrypt is my tool of choice, but I use this in scripts all the time:
encrypt:decrypt:
All of that being said, here's a PowerShell gem:
and then
For enabling remote desktop protocol remotely.
Disk Usage, human readable, 3 folders deep. Feel free to change depth and directory:
Code: Select all
du -ax --max-depth=3 /tmp/ | sort -n | awk '{if($1 > 102400) print $1/1024 "MB" " " $2; else print $0 }'
Code: Select all
perl -e '@r=(a..z,A..Z,0..9);$p.=$r[int(rand(@r))],$i++while($i<8);print"$p\n"'
encrypt:
Code: Select all
tar zcvf - /home/user | openssl des3 -salt -k secretpassword | dd of=/dev/st0
Code: Select all
openssl des3 -d -k secretpassword < stuff.des3 | tar zxf -
Code: Select all
psexec \\computername cmd
Code: Select all
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
Re: Post your Command line tricks
^ sounds like a hack ;)
Someone told me that I am delusional, I almost fell off my unicorn.
- wuxmedia
- Grasshopper
- Posts: 6454
- Joined: Wed Oct 17, 2012 11:32 am
- Location: Back in Blighty
- Contact:
Re: Post your Command line tricks
must have been old (or non-gnu) to use du with no '-h' option?
in the spirit of du'ing;
only find big files.
in the spirit of du'ing;
Code: Select all
du -sh /dir/ | grep [0-9]G
Re: Post your Command line tricks
Kind of a script (not cli) tip, but if you want to loop a sequence in bash, there is no need to use seq; bash can do this by itself.
Code: Select all
$ for n in {1..7}; do echo $n; done
1
2
3
4
5
6
7
Re: Post your Command line tricks
^ Thank You, very nice :)
If you can do it go ahead and do it, if you can't do it then don't even criticize it. - gingerdesu