[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: converting an array into a single variable
From: |
Dave Rutherford |
Subject: |
Re: converting an array into a single variable |
Date: |
Wed, 20 Feb 2008 21:44:12 -0500 |
On Wed, Feb 20, 2008 at 2:42 PM, Natan Shar <sharnatan@yahoo.com> wrote:
> I can do this with a few id numbers using php, but I need to do this with
> thousands of id numbers on a daily basis using a cron job
>
> I can successully build an array of the filenames using:
> declare -a imagelist='ls www/images/124534_*.JPG';
>
> But then I am stuck with the problem of srtipping the 'www/images/' off of
> each array element. I am trying:
> for file in ${imagelist[@]}
> do
> declare newfile=echo $file | sed 's/www\/images\///g'
> echo $newfile
> done;
More complicated than it needs to be.
ITEM=124534
imagelist=`cd www/images; echo $ITEM_*.JPG`
if [ "$imagelist" = "$ITEM_*.JPG" ]; then imagelist=""; fi
imagelist="${imagelist// /,}"
Nothing but builtins.
Dave