Re: Bash problems

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Eric \"Shubes\"
Date:  
To: plug-discuss
Subject: Re: Bash problems
Lee Einer wrote:
>
> Nathan England wrote:
>
>> I am trying to make a script that copies files from one directory to
>> another.
>> The problem is, some files have a space in between the names, think
>> "My Documents"
>>
>> I need a way in bash to copy a file from one directory to another.
>> At the same time, I need to be able to count the files.
>>
>> Currently, I'm trying something like this.
>>
>> find . | tee file_list
>> while read file
>> do
>> cp -ruv $file $TMP/backup
>> done < file_list
>>
>> This works great, but files such as "My Documents" can not be found by
>> cp. It sees it as My and Documents.
>>
>> I thought there was a way to get find to report the space with a
>> leading \ but I can't find that and I forgot how I did it before. Can
>> anyone help with this?
>> I greatly appreciate it!
>>
>> Nathan
>> ---------------------------------------------------
> Have you tried actually using double quotes as in "My Documents?" That
> should prevent the shell from reading the whitespace as a separation
> between two distinct terms.
> --
> Lee Einer
> Dos Manos Jewelry
> http://www.dosmanosjewelry.com


That should fix it all right.

The find command is quite powerful once you get to know it. If you don't
need the file list for some other purpose, you could simply:
find . -exec cp -ruv {} $TMP/backup \;

-- 
-Eric 'shubes'
"There is no such thing as the People;
  it is a collectivist myth.
  There are only individual citizens
  with individual wills
  and individual purposes."
-William E. Simon (1927-2000),
     Secretary of the Treasury (1974-1977)
  "A Time For Truth" (1978), pg. 237



---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss