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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to use sed or perl command to find and replace a directory in a file wip_vasikaran UNIX for Dummies Questions & Answers 1 08-20-2008 07:22 AM
Please Help. Strings in file 1 need to be searched and removed from file 2 mjs3221 Shell Programming and Scripting 4 08-18-2006 04:13 PM
file restoration to new directory - tar command newbie168 UNIX for Dummies Questions & Answers 2 07-19-2006 09:41 PM
after init all /tmp file has been removed yesthomas SUN Solaris 5 12-06-2005 06:48 AM
Copying file names returned from a grep command into another directory Kartheg UNIX for Dummies Questions & Answers 4 11-17-2005 12:34 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-19-2009
Leion Leion is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 16
cp && rm command, rm: <file> not removed. No such file or directory

Hi,

I am running this is korn shell


Code:
cp $source/$fname $dest/dir && rm $source/$fname

This was returned:

Code:
rm: /dir/file not removed: No such file or directory

The file could be found in the $dest directory which meant the cp was success.

The above code is used in a for loop to move many files


This script could run properly in another box with the same solaris OS but could not work properly on this box.

Is there something wrong with the command or is there something I missed out? Please help
  #2 (permalink)  
Old 01-19-2009
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,184

Code:
Space characters in the filenames?

cp "$source/$fname" "$dest/dir" && rm "$source/$fname"

  #3 (permalink)  
Old 01-19-2009
Leion Leion is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 16
Quote:
Originally Posted by methyl View Post
Code:
Space characters in the filenames?

cp "$source/$fname" "$dest/dir" && rm "$source/$fname"

no there are no space characters in the filenames...
  #4 (permalink)  
Old 01-19-2009
angheloko's Avatar
angheloko angheloko is offline
Registered User
  
 

Join Date: Jul 2008
Location: Philippines
Posts: 125
Code looks ok..

If you don't mind me asking, did you check if the file to be cp'd and rm's really is existing?
  #5 (permalink)  
Old 01-19-2009
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,184
Please post the full script.
Do you have any filenames with funny characters e.g. asterisk?
  #6 (permalink)  
Old 01-19-2009
Leion Leion is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 16
Quote:
Originally Posted by methyl View Post
Please post the full script.
Do you have any filenames with funny characters e.g. asterisk?
The for loop is using


Code:
 cd $source
for fname in `ls`
do
cp $source/$fname $dest/dir && rm $source/$fname
done

There are no funny characters in the filenames..

Last edited by Leion; 01-20-2009 at 01:49 AM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:50 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0