The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
absolute path Kirichiko UNIX for Dummies Questions & Answers 2 10-03-2007 03:30 AM
$PWD shows absolute path vs path w/symbolic links kornshellmaven Shell Programming and Scripting 3 06-13-2007 09:15 AM
absolute path filedeliver High Level Programming 4 06-05-2007 02:18 PM
vi - replacing a relative path with absolute path in a file Yinzer955i UNIX for Dummies Questions & Answers 2 09-07-2006 08:47 AM
HOW to make absolute path???? HELP youngvet High Level Programming 1 11-01-2003 01:58 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 05-14-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
From my first reply:

Code:
find . -type f -name 'tmp*' -print | ...
Reply With Quote
Forum Sponsor
  #9  
Old 05-14-2008
Registered User
 

Join Date: Jan 2008
Posts: 54
find & copy files with absolute path

Quote:
Originally Posted by era View Post
From my first reply:

Code:
find . -type f -name 'tmp*' -print | ...
thanks for reply
i tried this also but fail.
can u please give whole script.
Reply With Quote
  #10  
Old 05-14-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,314
Have you try to find out why it fails?
Put some effort into solving the problem with the given examples instead of always asking for the right answers.

Regards
Reply With Quote
  #11  
Old 05-14-2008
Registered User
 

Join Date: Jan 2008
Posts: 54
find & copy files with absolute path

Quote:
Originally Posted by Franklin52 View Post
Have you try to find out why it fails?
Put some effort into solving the problem with the given examples instead of always asking for the right answers.

Regards
thanks for reply

cd /home/jagannath.n
dated=$(date +%d-%m-%y)
test -d /home/jagannath.n/tmp/$dated | mkdir /home/jagannath.n/tmp/$dated
file=$(find . -name test* -print)
cp -rf $file /home/jagannath.n/tmp/$dated


my problem is solved using above script but it print below error .

cp: cannot stat `./Azureus': No such file or directory
cp: cannot stat `Downloads/SHELL': No such file or directory
cp: cannot stat `SCRIPTING': No such file or directory
cp: cannot stat `IN': No such file or directory
cp: cannot stat `LINUX/VTC': No such file or directory
cp: cannot stat `-': No such file or directory
cp: cannot stat `UNIX': No such file or directory
cp: cannot stat `SHELL': No such file or directory
cp: cannot stat `SCRIPTING': No such file or directory
cp: cannot stat `ADVANCED/Course': No such file or directory
cp: cannot stat `Files/Chapter': No such file or directory


is it error?
Reply With Quote
  #12  
Old 05-14-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
It's because you don't quote the arguments properly. But just adding double quotes around "$file" doesn't really help, either, because it's not a single file. I'd still recommend using tar or cpio for this.

Note there are two |:s before the mkdir, it's an "or"; "a || b" is a shorthand for "if not a then b" (which is equivalent to "a or b").
Reply With Quote
  #13  
Old 05-15-2008
Registered User
 

Join Date: Jul 2006
Posts: 189
try this

Code:
#! /usr/bin/ksh

cd /home/backup/
find /home/abc/ -name "*.s" | while read line
do
  p=$(dirname $line )
  p1=$(echo $p | sed 's/\///')
  mkdir -p $p1
  cd $p1
  tocopy=$(pwd)
  echo $tocopy
  cp $line $tocopy
  cd -
done
Reply With Quote
  #14  
Old 05-15-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
That will still not cope with file names with spaces in them. Proper quoting, please!!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
cpio, linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0