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


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

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-15-2008
Registered User
 
Join Date: Aug 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Move command problem

In my shell script I am searching a log file, creating a directory and have to move the searched logfile into the directory.This is the way I wrote:


ZIP_LOG_FILE=`find . -name "${LOG_FILE}" -print0| xargs -0 tar zcf FILE`
mkdir temp_log
mv -f ${ZIP_LOG_FILE} temp ....

this is a piece of the script....and I get this error:
mv: missing destination file operand after `templog'
Try `mv --help' for more information.

What could be wrong??......
Sponsored Links
    #2  
Old 02-15-2008
Registered User
 
Join Date: Feb 2008
Location: stockholm sweden
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
to answer your question about mv- your first param which is a variable is probably empty, resulting in a mv expression with only one parameter. Thats why its complaining.

I'd write it in another way, try this:


Code:
saved_ifs=$IFS; IFS='
'
for $file in $(find $search_here -type f -name "$LOGFILE" ) ; do
  mkdir -p $savedir
  mv -f "$file" $savedir
done
IFS=$saved_ifs

If you dont need to worry about filenames with whitespaces in them, you can remove the first, second and last line.

cheers
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help with move command eskay Shell Programming and Scripting 8 04-17-2012 07:38 AM
Copy or Move problem sraj142 Shell Programming and Scripting 9 09-12-2011 04:10 AM
Move Command and exit status problem visingha Shell Programming and Scripting 10 09-13-2008 08:08 PM
Move Command and exit status problem visingha UNIX for Dummies Questions & Answers 1 09-12-2008 02:14 AM
move command thepurple Solaris 3 10-06-2007 07:26 AM



All times are GMT -4. The time now is 07:44 PM.