LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-08-2005, 11:28 AM   #1
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,197

Rep: Reputation: 45
Unhappy bash my little bash


Hi ...reading the manual for the find command i have just written a script that finds the files that have been modified since the time that a specific file was created...

find $1 -name /etc/timestamp -mindepth $1

find exactly returns what i need... now i want to copy all these files to a specific dir..

I have tried to copy them using the command
cp `find $1 -name /etc/timestamp -mindepth $1` $SAVETODIR

It propably works fine.... but still has a problem that i want to remove

If one of the files being copied is damaged or something else... then the copy stops .....
I want to handle that situation and simply skip the corrupted file and proceed with the remaining......

So i think that the best i need to do is a for loop iteration so i can easily skip the files that have some kind of problem...

Plz suggest me a way for writing that code.....

Thx alot..
Have a nice day

Last edited by alaios; 01-08-2005 at 12:03 PM.
 
Old 01-08-2005, 11:54 AM   #2
kornerr
Member
 
Registered: Dec 2004
Location: Russia, Siberia, Kemerovo
Distribution: Slackware
Posts: 893

Rep: Reputation: 35
Man! My English is awful, but...
I didn't understand what you want.
You want to find neede file and... I don't underst& u.
May be I'm too stupid???

PS: Never use Mandrake! It's the worst distribution. Slackware FOREVER!!!
 
Old 01-08-2005, 12:39 PM   #3
MadNewbie
Member
 
Registered: Jun 2003
Posts: 31

Rep: Reputation: 15
Perhaps you can try something like this


for var in `find $1 -name /etc/timestamp -mindepth $1`
do
`cp $var /path/to/copies/`
done
 
Old 01-08-2005, 12:52 PM   #4
Vookimedlo
Member
 
Registered: Jul 2004
Location: Czech Republic - Roudnice nad Labem
Distribution: Debian
Posts: 253

Rep: Reputation: 34
Even I don't know what this exactly do: find $1 -name /etc/timestamp -mindepth $1


The solution from MadNewbie doesn't work for filenames with spaces.
This is more effective. and works correctly.

find $1 -name /etc/timestamp -mindepth $1 -print0 | xargs -iXX -0 cp XX /path/to/copies/
 
Old 01-10-2005, 11:59 PM   #5
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,197

Original Poster
Rep: Reputation: 45
thx

thx a lot... now somethign more strange,.. I need to copy the files but also to create the directories if they don't exist ...cool eh?

for example

cp -(parameter) /etc/rc.d/rc.inet1 $mypath

lets say that $mypath is /mnt/floppy

i want after the execution of the command written above the file to be copied to the right directory which is /mnt/floppy/etc/rc.d/rc.inet1
How i can do that...copy and create the directorieds dynamically?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
$LINENO can't be modified in bash 3.0, while it can be in bash 2.05b Darwish Linux - Software 1 11-07-2005 02:57 PM
BASH help snorky Linux - General 3 03-18-2005 07:27 PM
bash + html + javascript or just bash ? rblampain Programming 4 12-01-2004 07:53 AM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM
Bash Half_Elf Linux - General 2 05-01-2002 06:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration