Command-Line Tricks

less than 1 minute read

So, I always am using some command line shortcuts to do various tasks, and often have to look up the tricks every time I need to do something remotely fancy.  Here are some of my most-used helpful hints:

  • To remove the leading spaces and tabs from each line of text on standard in (so use with a pipe for the input), this sed command will work well:
      sed -e 's/^[ \t]*//'
    
  • Reformatting XML/HTML files so that line returns inside tags are removed:
      xmllint --format --noblanks infile.xml > outfile.xml