parallel
[Top][All Lists]
Advanced

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

Re: {/} as basename


From: Ole Tange
Subject: Re: {/} as basename
Date: Wed, 27 Oct 2010 21:54:09 +0200

On Wed, Oct 27, 2010 at 7:06 PM, Hans Schou <chlor@schou.dk> wrote:
> On Wed, 27 Oct 2010, Ole Tange wrote:
>
>> {.} is a shorthand for removing from the last . in the filename (and
>> thereby removing the extension if any).
>>
>> I am thinking of implementing a similar for basename, so you can get
>> the filename without the path. My idea is to use {/} as the basename
>> variable.
>>
>> Would it be useful?
>
> I think so.
>
> Take one copy of all files. Skip dir. Overwrite duplicates:
>
>  find | parallel cp {} /tmp/{/}

This could be written as:

find | parallel -X cp {} /tmp/

or even:

find | parallel cp {} /tmp/

which is shorter and IMO more readable. Can you think of a better situation?

>> If so, what should the corresponding {2} and {2.} be called? Maybe:
>> {2/} and {2/.} ?
>
> What is the difference between:
>  {2.}
>  {.2}

{.2} does not work. Only {2.} works.

> It must be something about how you delete.
>
> {2/} or {/2} must then imply: remove 2 dirs from start or end of path.

The 2 is the positional argument when you read in tables:

echo foo/bar.a baz/quux.b| parallel --colsep ' ' echo 2:{2} 1:{1.}

The 2 does not have anything to do with how many / are being removed.
{2/} should simply run 'basename' on the 2nd argument. So:

echo foo/bar.a baz/quux.b| parallel --colsep ' ' echo 2:{2/} 1:{1./}

would print:

quux.b bar


/Ole



reply via email to

[Prev in Thread] Current Thread [Next in Thread]