Renaming Files With Underscores

Through the past 20 years I have written hundreds of shell scripts that are stored in my /usr/local[s]bin directories. In the file names some scripts contained underscores and some dashes. Dashes are easier to type by avoiding the Shift key.

I wanted to rename most of the scripts using underscores to names using dashes.

That sounded easy until realizing that scripts are used and sourced in other scripts and files. Thus began the hunt for all such locations.

I wrote yet another shell script to search and replace references of the old file name to the new file name. The exercise revealed that sometimes what seems to be an easy task is actually complicated. There were many places where a script could be used or referenced.

  • /etc/X11/xinit
  • /etc/bashrc
  • /etc/cron*
  • /etc/functions-* (common functions sourced in scripts)
  • /etc/logrotate.d
  • /etc/profile.d
  • /etc/rc.d/rc.*
  • /usr/local/bin
  • /usr/local/sbin
  • /usr/local/share/applications
  • /var/spool/atjobs
  • sym links
  • $HOME/.bash_logout
  • $HOME/.bash_profile
  • $HOME/.bashrc
  • $HOME/.config/autostart
  • $HOME/.local/share/applications

The new script worked well. Through the next several days nothing broke on the system.

Posted: Category: Usability Tagged: General

Next: ISP Snooping — 3

Previous: Updating Slackware — 3