Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FIND with OPTION NEWER

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have a problem today with a simple shell script. Can any one help me to sort this out.

I am checking the last file on the remote machine then find files on the local machine that have been modified recently than files on the remote machine.

My command was

$ LAST=” `rsh REMOTEHOST ls –t /REMOTEDIRECTORY | head –1` ”


$ find . –newer $LAST –type f –print

I get an error message for this.

CANNOT ACCESS $LAST
 
Thanks you but I still get the same error message

find:cannot access last
 
Try sticking a "print $LAST" in there to see if $LAST has a value. If so, and it is the correct one, it would be something with find.
 
Sorry - that's garbage!

Try adding ;export LAST to the end of your LAST=...etc... command.
 
Sorry Yegolev, I didn't mean your post was garbage, I meant my previous one was! Obviously posting at the same time. It's been a long day!
 
Hehe, yeah I figured that, Ken. =) I was thinking, looks like we are mixing CAPS and lower in the prob description... wonder if that's a typing thing.

Could be rsh doesn't work and $LAST is empty? If this were the scripting forum, I'd suggest some error-checking in the script.
 
I think I managed to figure it out the reason.

Variable LAST contains a name of a file. (on the remote machine)

When it is exported to the local machine there is no file in that name to check the time stamp.
So I copied the $LAST to the local machine with -p option.

Now I have a real file to compare with what is on my local machine.

With this, it worked. !!!

Many thanks to all of you for your valuablr advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top