5 ms·
What is your favorite command-line trick using Bash?
- kunley 16y agoMy favorite bash trick is to use it to install zsh and move on. But seriously. C'mon people please stop saying bash when you really mean command line of a typical Unix. Same for saying Linux when you mean a family of Unices. Please also consider your combination of OS, shell and editor isn't the only one reasonable and widely used around. Thanks.
- slindstr 16y agoI'm pretty forgetful when it comes time to figure out which files I've modified recently so I'm a big fan of making a timestamp file: touch -t 201011271200 timestamp and then finding the files that are newer than that timestamp: find . -type f -newer timestamp It's especially helpful since Zend Framework has such an arduous file structure sometimes.
- slindstr 16y agoAlthough in hindsight, I guess that's not really a bash trick, just more of a command line trick...
- Despite 16y agoHmm, that's interesting. My first response was "Surely, find can do that without creating a new file." But it looks like the other options only take a number of minutes, or a number of days, not a timestamp. That's a strange deficiency.
- jttttt 16y agobefore: $ ps ax | grep myapp | grep -v grep | {...} after: $ ps ax | grep [m]yapp | {...}
- sumeeta 16y agoHow does this work?
- Despite 16y agogrep treats "[m]yapp" as a regex, which will match "myapp" but not itself. That is, it won't match the exact string "[m]yapp" so the grep process won't show up in the listing.
- antifuchs 16y agoOh my. Do use pgrep. It's much more robust (what do you do if you have to search for a process named "0:0"?), and you don't have to use pipelines and strange regex tricks (which will fail to work on zsh with "set nomatch" if you don't quote, for example).
- ithkuil 16y agoappend something to some file owned by root, without running a root shell but just 'sudo': echo something | sudo tee -a somefile useful since "sudo echo something >somefile" will not do the job, as the redirect is performed by your shell, not the command being executed
- zitstif 16y ago#Anyone hear of dog? dog is better than cat.. dog http://ifconfig.me http://ifconfig.me | egrep -wo '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}' | uniq