On Wed, 2007-05-16 at 10:24 -0600, Paul Seamons wrote:
> Do you say that because the bash solutions (repeated below) are soooo much
> more intuitive? I'm just poking and not all that serious - I could've added
> newlines and comments to the perl but then it wouldn't have been a one liner.
>
I, for one, would be grateful if your would post your perl snippet with
newlines and formatting.
To your question, I would argue, "yes. Yes they are sooo much more
intuitive."
>
> Somebody fluent in bash can understand these examples, but the same goes for
> the perl solutions and somebody semi-fluent in perl. To somebody versed in
> neither, both may as well be Greek even though they get the job done.
Most of us on this list, which includes me, are not as well-versed in
bash as you are in perl. Yet bash scripts are often, while blunt and
brutal, easier to understand.
I have seen malicious perl one-liners before (I know yours is not!). I
have also seen malicious bash scripts before. But I can at least tell
you why the bash script was malicious. To this day I don't know what the
perl scripts do.
In the hands of the adept, perl is powerful magic indeed.
> > for file in *; do
> > new_name=$(echo $file | sed 's/^\([0-9]\{5\}\).*/\1/')
> > echo Renaming "$file" to "$new_name"
> > mv -v "$file" "$new_name"
> > done
>
> > find * -type d -maxdepth 0 | while read $d; do
> > tgt=`expr substr $d 1 5`
> > mv $d $tgt
> > done
>
> > do
> > src=$i
> > tgt=`expr substr $i 1 5`
> > mv $src $tgt
> > done
>
> Personally I would fire up emacs, use dired mode on the directory, and do
> a %-R which is dired-do-rename-regexp which interactive allows you to rename
> files based on a regular expression. I have used this on many occasions - it
> prompts for each file showing what you are renaming to as you go.
I believe there is a rename utility that is pretty standard that can
also do this from a shell prompt.
>
> Paul
>
> /*
> PLUG: http://plug.org, #utah on irc.freenode.net
> Unsubscribe: http://plug.org/mailman/options/plug
> Don't fear the penguin.
> */
>
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/