Operating System - HP-UX
1844070 Members
3031 Online
110227 Solutions
New Discussion

Re: Problem with white space in file names

 
David Vanidour
New Member

Problem with white space in file names

Ok, heres hopeing someone out there has run into this before and can suggest a
work around for this.

We have an HP 9000 running HP-UX 11 that we are running an application (Oracle)
database on. The user has a directory NFS mounted onto this machine that (I
think but don't quote me) originates on a Windows NT server somewhere. I've
been asked to backup this NFS mounted directory at the same time as I backup
the database... which would normally not be a problem.

My normal backup script takes care of the backup and places the backup files
(either an Oracle export or copies of our Oracle database files depending on
what kind of backup has been performed) to where our Unix Administrator has
configured his backup software to worry about these files. The NFS mounted
directory is ignored by his sofeware. So I added a subscript to copy the files
to an appropriate directory. Now I've gotten into the habbit of using for
loops when moving groups of files around because I don't get a copy, remove or
move command trying to walk a directory tree when all I want to do is work on
the files in a given directory. My working script looks like the following.

for AL in `ls /dirname2/ | awk -F '{ print $1 }'`
do
rm /dirname2/${AL}
done
for AL in `ls /dirname1/ | awk -F '{ print $1 }'`
do
mv /dirname1/${AL} /dirname2
done
for AL in `ls /NFSdirname/ | awk -F '{ print $1 }'`
do
cp /NFSdirname/${AL} /dirname1
done

The problem is that some of the NFS mounted files have file names with
whitespace in them.

For example: "The last file accessed.xls" could be a file name and the "for"
interprets this as four distinct names instead of one name.

Any suggested work arounds to this would be greatly appreciated.
7 REPLIES 7
Rick Taylor_5
Advisor

Re: Problem with white space in file names

You might be able to use the find command instead of a for loop i.e.:

find /dirname/ -name whatever\* -exec mv {} /newdir \;

Re: Problem with white space in file names

You can almost always sub the find command for the ls in your script. It would
also take care of the need to loop. Also takes care of the white space
problem.
For example: "find / -name "app*" or
"find / -name "*app*".. You can really get creative here.
Rich
Peter Brimacombe_1
Occasional Advisor

Re: Problem with white space in file names

or spend more money:

buy OmniBack, you will pay for the cell server, plus licenses for concurrent
tape drives, plus client license for NT servers: about $5000 U.S.

- back up all HP-UX data without the extra copy step
- back up NT data directly from the NT box without the extra copy ( could you
restore it to the NT box?)
- do cold backups of the Oracle database with no copy step
- after alot of hard work studying Oracle Record Manager, Oracle/Omniback
Integration you can do hot backups directly to tape (sans export files) but
don't think that it is easy
- automatic log creation/management
- ability to intuitively search logs
- tape management (given the directory and the date on which it was backed up,
what tape is it on?)

Re: Problem with white space in file names

Hi there

You could rewrite your script like this:

for AL in /dirname2/*
do
rm "${AL}"
done
for AL in /dirname1/*
do
mv "${AL}" /dirname2
done
for AL in /NFSdirname/*
do
cp "${AL}" /dirname1
done

or rewrite to:

cd /dirname2
rm -rf *
cd /dirname1
find . -print | cpio -pudvmx /dirname2
rm -rf *
cd /NFSdirname
find . -print | cpio -pudvmx /dirname1

good luck
Jesper Sivertsen
David Vanidour
New Member

Re: Problem with white space in file names

Peter,

Thank you for your response.

I was not looking for either an advertisement to purchase OmniBack or
suggestions for the local UNIX administrator on how he should do his job
however.
David Vanidour
New Member

Re: Problem with white space in file names

Richard,

Thank you for your response.

Nice suggestion and I did investigate the possibility myself. I could not get
it to work very satisfactorally however... my own inexperience I am sure.

I found Jesper Sivertsen's suggestion to be the most helpful.

David
David Vanidour
New Member

Re: Problem with white space in file names

Rick,

Thank you for your response.

I did investigate using the find command myself but was not successful in
producing any satisfactory results... my own inexperience perhaps?

I found Jesper Sivertsen's suggestions to be the most applicable however.

David