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

Re: Bash script problem [OT?]



On 22/04/12 22:02, Soare Catalin wrote:
On Sun, Apr 22, 2012 at 10:25 PM, Dom<toyer@rpdom.net>  wrote:

On 22/04/12 08:34, Cam Hutchison wrote:

Soare Catalin<lolinux.soare@gmail.**com<lolinux.soare@gmail.com>>
  writes:

  The script will take files or dirs as parameters and will back them up
in a
presefined location, using tar. Problems arise when it will encounter
files
or directories which contain spaces in their names.



So again, thank you very much for your responses, but the only thing in my
mind for the moment is that I really have to go back to the abs-guide (or
perhaps find another one?) -- bottom line is that there's so many things
I've forgot/not used for anything else than to follow a tutorial...


Have you considered writing the file/directory names out to a temporary file and using that for tar input?

The list file should be initialised first with

  >${TMPDIR}/BK_LISTFILE

Change the BK_LIST="$BK_LIST ${PARAM}" lines to:

 echo "${PARAM}" >> ${TMPDIR}/BK_LISTFILE

and the tar line to:

  tar -cjf $BK_FULLPATH -T ${TMPDIR}/BK_LISTFILE

Finally tidy up with:

  rm ${TMPDIR}/BK_LISTFILE

No need to worry about any quoting or special characters in names this way.

(The tempfile command is very useful for creating temporary files for this sort of thing)
--
Dom


Reply to: