David Guntner <da...@guntner.com> writes:

> Mark Carroll grabbed a keyboard and wrote:
(snip)
>> for i in *_????????_default\.m??
>> do mv "$i" "`echo $i | sed 's/.\{17\}\(.\{4\}\)$/\1/'`"
>> done
>
> Ooh, yea, that looks like it would do it, way better than what I came up
> with if it doesn't require a specific number of fields.  I'm a little
> vague on my sed syntax, though.  Could you break that down and explain
> how that's doing what it does?

Sure. First, the \ in the first line is superfluous. (-:

The sed replacement is:

- 17 characters, the count marked within \{ \}
- 4 characters is capture group 1, marked within \( \)
- the end of the string, marked with $
replace with
- group 1, marked with \1

So,
- the 17 are for the _????????_default
- group 1 is for .m4a
to replace _????????_default.m4a with .mp4

Using the $ to anchor to the end of the string is the key here. I can be
sloppy about what characters match because the glob in the for loop did
my matching for me.

-- Mark


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/87bny8rtra....@ixod.org

Reply via email to