[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Multiple double quoted expansions
From: |
Pierre Gaston |
Subject: |
Re: [Help-bash] Multiple double quoted expansions |
Date: |
Sun, 1 May 2016 08:14:47 +0300 |
On Thu, Apr 28, 2016 at 4:26 AM, David Niklas <address@hidden> wrote:
> Hello,
> Today I typed into my terminal (">" changed to "<"):
>
> % for i in *.pcx; do
> < convert "$i" "$(basename $i .pcx).png";
> < done
>
> This worked well, but all the filenames contained no embedded spaces
> or anything else. So my question is, how would I redo this to make
> it handle nastier filenames?
>
> Thanks, David
>
> quote the $i inside the $( )
"$(basename "$i" .pcx).png";
you can also use parameter expansion:
convert "$i" "${i%pcx}png";
for extra safety you can use:
for i in ./*.pcx
this can avoid trouble with filenames starting with eg -