Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

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
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
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`
`cp $var /path/to/copies/`
Old 01-08-2005, 12:52 PM   #4
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
Senior Member
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Original Poster
Rep: Reputation: 45

thx a lot... now somethign more strange,.. I need to copy the files but also to create the directories if they don't exist 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?


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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:53 PM.

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