Re: Renaming (was: Hpodder-and-Torsox)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On October 23, 2014, Hart Larry wrote:
> I find it interesting, you are not useing a dot for an extention. 

I could have included it:

  rename 's/\.txt$/.htm/' *.txt

but

(1) the file-glob(s) at the end limit the action/changes to those with
a dot before the extension,

(2) the "$" anchors it to the end of the file-name, so a file like
"my_txt.txt" won't be turned into "my_htm.txt" (or "my_htm.htm" if
you added the "g" flag after the last slash),

(3) the initial period might need to be escaped in certain cases,
only to put it back in later.  That's extra unneeded typing.

That's a lot of hassle for this use-case, so I just omitted them
because I'm lazy. (grins)

> So, not only am I wondering an easy way of doing that in tcsh, but
> how simple would it be of creating something which would mirror
> that DOS "ren" command?

Because the shell expands wildcards before the program ever sees
them, you'd need to annoyingly quote them:

 bash$ fancy_rename "*.txt" "*.html"

and then the program would have to unglob them and make the
transformation.

Hope this helps,

-tim





_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/blinux-list




[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]