Earlier quoted context omitted.
> You know what else I hate? Typing in long commands in the Mac OS X terminal and then them wrapping weirdly. Yeah, keeping ctrl pressed in and pressing x followed by e (CTRL + x e) will open up the current line in $EDITOR and when you edit and save, replaces the current line with what you entered in your editor. Really a killer feature.
In Linux with bash (and probably other shells that are bash-compatible), you can use vi to edit any of the commands in your command history, and then execute the edited version. Do this at the command prompt, or once in your ~/.bash_profile to make it permanent: set -o vi After that, you can search for any of the commands in your history, edit it, and then execute the edited command, by doing this: At the prompt, typ…
Unix Tricks
131–140 of 166 posts
Re: Unix Tricks
#132Very handy if you do something silly like cat a binary file without piping it into strings -a
This restores the terminal settings and sanity restored. Note you will often find yourself typing without seeing anything, least until you enter and execute the sane.
Also asvise the following usage ctrl+c a couple of times to clear anything out of the input buffer queued up. stty -sane all good from here onwards and good time to play with od and remember the strings -a pipe next time.
Re: Unix Tricks
#133Earlier quoted context omitted.
I still prefer "sh" on BSD (particularly OpenBSD). It doesn't have as many knobs to turn nor as many surprises.
sh, the Bourne shell mode of pdksh? Isn't that a little too limited? pdksh (/bin/ksh) though is great, yes. I'm in general a big fan of the OpenBSD userland: straightforward and very, very well-documented. Real manpages, no religious "The full documentation for xyz is maintained as a TeXinfo manual" crap. A well-conceived featureset and good docs are key to properly learning a platform. OpenBSD taught me a lot about…
Also anything that will run script wise on bourne will run as is under korn.
Though you may well find that it is historical, which one a user picks shell wise. People who started or worked a lot with Sun systems will be csh fans. Old vets more inclided to bourne, though very few. As for korn shell, that would be mostly down to AIX systems as that is the default upon them as with the other systems mentions, default wise. Then for Linux you will find a bias towards bash.
Least that is what I have observed.
Though history does give us some intersting trends and the awk, perl, python transition and preference will also mostly be down to when somebody got into unix as a whole. Again old school, awk. Old, perl and not so long ago the python brigade.
But that is just a rule in thumb and more helpful in explaining why there is a solo perl script when everything else done in xyzzy type encounters.
As for OpenBSD, good choice, I prefer it due to the file system layout and more akin to old school unix unlike Linux which is `creative` more than not in choices, so feels less at home.
Still back in the early days we had AT&T and Berkly BSD flavours and with that the ps command, oh the fun and games.
But least thinks a little bit more common across flavours than before and yet still each has there own quirks.
Re: Unix Tricks
#134Earlier quoted context omitted.
It's actually Meta , emulated by an ESC character by the terminal. OSX tip: check "use Option as Meta" in Terminal's preferences, and you can keep Option pressed while you mash ".".
Which is fine if you never need to generate characters using the Option key. For example on a German keyboard you need the Option key to write { or }.
It also has the side effect of "resurrecting" dead keys (which are unrelated to Option), making input of 'ê'and 'ï' impossible.
An alternative is using iTerm2 which has a similar setting, liberally applyable to either Option key.
Re: Unix Tricks
#135Ctrl-V: type next input literally (e.g. Ctrl-V [Tab] if you don't want [Tab] to autocomplete).
Alt-#: Prefix current line with "#" (don't execute it) and put it into history for later use.
I'm sometimes surprised how many people don't know these: Ctrl-U/K: kill line before/after cursor.
Re: Unix Tricks
#136Re: Unix Tricks
#137I call this one sshping. while sleep 0.1; do nc -w 1 -z host 22; done Useful when waiting for systems to boot.
@reboot /bin/date | /usr/bin/mail -s "$(/bin/hostname) booted" root@example.com
If you don't want to configure postfix as a smarthost (which is not that hard and recommended if only to have mail queued for retry), use ssmtp.Re: Unix Tricks
#138Ctrl+r is fine when you're looking for something recent, but this one is useful when you're looking through a long list of similar commands. alias hist='history | grep' Use it like this: $ hist git 9543 git add toto 9544 git commit 9545 git log 9546 git log 9548 git add -A 9549 git commit 9550 git log 9633 git pull 9955 cd dev/git 9957 git grep copyof 9958 git grep copyof 9959 git pull By the way, do you know you can…
Re: Unix Tricks
#139Its implied on the list but not mentioned specifically. !! will be substituted with the last command you typed. So if your somebody like me who frequently types $ apt-get update Could not lock yada yada are you root? $ sudo apt-get update instead you can type $ apt-get update $ sudo !!
Same thing for the last argument, it's easily edited if you know the right shortcuts: Ctrl-P Alt-B Ctrl-U. (Works for bash, for zsh you need http://stackoverflow.com/q/3483604/414272). That said, I didn't know about Alt-.
Re: Unix Tricks
#140Earlier quoted context omitted.
I still prefer "sh" on BSD (particularly OpenBSD). It doesn't have as many knobs to turn nor as many surprises.
sh, the Bourne shell mode of pdksh? Isn't that a little too limited? pdksh (/bin/ksh) though is great, yes. I'm in general a big fan of the OpenBSD userland: straightforward and very, very well-documented. Real manpages, no religious "The full documentation for xyz is maintained as a TeXinfo manual" crap. A well-conceived featureset and good docs are key to properly learning a platform. OpenBSD taught me a lot about…
Shell scripts really don't scale development-wise over time.
Definitely agree with the rest of the points though.