help-bash
[Top][All Lists]
Advanced

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

Re: Change filename extension in Bash array


From: Jeffrey Walton
Subject: Re: Change filename extension in Bash array
Date: Mon, 25 Jan 2021 06:54:33 -0500

On Mon, Jan 25, 2021 at 5:17 AM Andreas Kusalananda Kähäri
<andreas.kahari@abc.se> wrote:
>
> On Mon, Jan 25, 2021 at 10:47:03AM +0100, Reuti wrote:
> >
> > > Am 25.01.2021 um 10:41 schrieb Jeffrey Walton <noloader@gmail.com>:
> > >
> > > Search is not turning up the results I am looking for. I would appreciate 
> > > help.
> > >
> > > I have an array with filenames:
> > >
> > >    odt_files=("ch1.odt" "ch2.odt" "ch3.odt" ...)
> > >
> > > I convert the ODT to a PDF using lowriter, which is a LibreOffice utility.
> > >
> > > I need to combine the PDFs using pdfunite for the final document.
> > >
> > > How do I create an array of filenames using the PDF extension given
> > > the ODT extension in odt_files?
> > >
> > >    # What is needed here?
> > >    pdf_files=${odt_files}
> > >
>
> You probably want "${odt_files[@]/%.odt/.pdf}" here, including the
> quotes and the %.
>
> The quotes are needed in case any string contains characters from
> $IFS (space, tabs, newlines by default), or if they contain globbing
> patterns.
>
> The % is needed to only delete the .odt substring from the end of each
> element (not the first found .odt).

Thanks everyone.



reply via email to

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