more or less useless tips and tricks 2
More or less useless/useful tips and tricks, bundled together. They
weren’t worthy of a box div on their own. I gave them only a li
each.
kill -WINCH $$— when your terminal is messed up where the row moves up one line before you’ve reached the line-length ($COLUMNS):
aSIGWINCHsignal to the current shell will make everything alright again.hash -r— you moved applications around in your$PATHandbashclaims that some applications don’t exist in your$PATHeven though you (andls) know that they do:
the hash command will flush the path cache.- Multiple sed expressions can be combined like this:
sed -e '1d;s/abc/def/'— by using a semicolon, or
sed -e '{ 1d s/abc/def/}— by using curlies and line feeds. - By removing lines with sed you don’t need a
grep -vcommand in your Command Line Fu:
sed -e '/HEADER_MATCH/d;s/needle/haystack/'— usually works better than usingsed -nand is more performant than adding separategrepcommands in the mix. Use'/needle/!d'to search instead of delete. - Multiple vim expressions? Use the pipe:
:%s/abc/def/g|%s/foo/bar/g|wn - Inserting vim modelines in lots of files:
find . -name '*.py' | while read x do [ -s "$x" ] && (sed -e '1p;q' "$x" | grep vim: -q || sed -i -e '1i# vim: set ts=8 sw=4 sts=4 et ai:' "$x") done - What’s the
ulimit -ccore file block size? It should be 512 bytes. But when called frombashit might be 1024. Soulimit -c 2097152would limit core dumps to max 1GB or 2GB. - Underscores or dashes in Asterisk context names? You’ll be
looking at channel names that look like this
Local/some_device@some_context-7f82,1. As you can see, the dash is used already. Prefer the underscore.