• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

how to read file name which contains space?

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks, Andrew Monkhouse
It works fine.
 
If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!