News for hackers. Stuff that matters.
Re:UNIX tips: Learn 10 good UNIX usage habits by mark-t on Sunday January 27, 2008 @11:52AM (#105018)
> Really? How often will I need to make a directory structure that is several levels deep, but only one directory at each level?

Didn't take me long to find one in my scripts directory. Just imagine you're doing something similar by hand:

  #!/bin/bash

  # This script strips debugging symbols from programs and stores them separately.
  # They will be loaded by gdb when needed but will not take up memory when
  # running the program normally.

  # determine where to save debugging symbols
  DEBUG_PATH="/usr/lib/debug"
  if [[ ${EUID} != 0 ]]; then
    DEBUG_PATH="${HOME}/lib/debug";
  fi

  # go through list of command line arguments and split each one
  for x in "$@"
  do
    echo "Splitting ${x}"
    y="${DEBUG_PATH}${x}.debug"
    mkdir -p "$(dirname $y)"
    objcopy --only-keep-debug "${x}" "${y}" || continue
    objcopy --add-gnu-debuglink="${y}" "${x}" || continue
    chmod a-x,o-w "${y}"
    strip "${x}"
  done

There are no comments on this comment yet.