more or less useless tips and tricks 2

more or less useless tips and tricks 2

  • Written by
    Walter Doekes
  • Published on

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):
    a SIGWINCH signal to the current shell will make everything alright again.
  • hash -r — you moved applications around in your $PATH and bash claims that some applications don’t exist in your $PATH even though you (and ls) 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 -v command in your Command Line Fu:
    sed -e '/HEADER_MATCH/d;s/needle/haystack/' — usually works better than using sed -⁠n and is more performant than adding separate grep commands 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 -c core file block size? It should be 512 bytes. But when called from bash it might be 1024. So ulimit -c 2097152 would 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.

Back to overview Newer post: callerid in rpid / opensips / kamailio Older post: Upgrading Ubuntu command line