• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to read file name which contains space?

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to read file name which contains space using command 'find'?

for example: 'abc 1234_temp.doc' this is file name on linux, i want to find this file name using linux cmd 'find'. but i got file name as abc.

can any one help me in that?
 
Ranch Hand
Posts: 225
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can find the file:but to process it properly you will need to use the -print0 option, and something like -0 (number zero) to xargs. For example:would pass all the filenames found in the arguments to xyz.Main, even with spaces or control characters in the names.
 
Rahul Dhaware
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Carey Evans for reply.

But i want different.

suppose i have a directory 'dirName' in linux.
in that there are two files with today's last modified timestamp.

dirName
|
|
---> new FileName1.txt
---> old File 100.txt

folder and files are as shown above.

and to get these files according to there last modifield timestamp i have written a small shell script as below:

for file in "$( /usr/bin/find /usr/dirName -type f -mtime 0 )"
do
cp -rf $file /home/BackupDirName
done


so i execute above script i got following errors:

cp: cannot stat `/usr/dirName/new': No such file or directory

Can any one help me to solve this problem?
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One way of handling this is to change your logic so you are piping the output of find through something that works on a line-by-line basis:



Regards, Andrew
 
Carey Evans
Ranch Hand
Posts: 225
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also run the command from find:If this gets much more complicated, you should look into rsync.
 
Rahul Dhaware
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Andrew Monkhouse
It works fine.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic