home bbs files messages ]

Just a sample of the Echomail archive

<< oldest | < older | list | newer > | newest >> ]

 Message 326 
 andrew clarke to Ben Ritchey 
 Favs 
 24 May 16 04:39:50 
 
23 May 16 12:54, you wrote to Wilfred Van Velzen:

 BR>>>>> Ok, here's a good one, what is your favorite Bash script?
 WV>> What kind of answer did you expect? ;)

 BR> Really? Ok, here's my fav, renames EVERYTHING from current folder
 BR> recursively to lowercase:

Strictly speaking this can be simplified to your one-liner command though,
which isn't bash-specific.

 BR> find ./ | sort -r | sed 's/\(.*\/\)\(.*\)/mv "\1\2" "\1\L\2"/' |sh

On some systems the "sh" command is not necessarily bash, eg. in Ubuntu it's
dash, on FreeBSD it's FreeBSD's sh.

Usually when people refer to bash scripts what they really mean are sh
scripts, or scripts that will run under a POSIX 1003.2 compliant shell, of
which bash is one.

It's usually a good idea to avoid using bash extensions in scripts.
Fortunately this isn't common.

csh (and tcsh) is another beast entirely and isn't POSIX 1003.2 compliant. I
prefer tcsh (vs bash) as a command interpreter, but any shell scripts I write
will be for /bin/sh.

Lastly, you might find that if your shell scripts ever begin to get
complicated you'll want to rewrite them in a more suitable language (Python is
common). Robust sh scripts tend to be difficult to understand and debug when
there's a lot going on, and can fail in strange ways...

--- GoldED+/BSD 1.1.5-b20160201
 * Origin: Blizzard of Ozz, Melbourne, Victoria, Australia (3:633/267)

<< oldest | < older | list | newer > | newest >> ]

(c) 1994,  bbs@darkrealms.ca