LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 06-27-2005, 06:42 PM   #1
dickb
LQ Newbie
 
Registered: Jun 2005
Posts: 15

Rep: Reputation: 0
Copy all files with .htm extension


I am using Knoppix 3.8.2

I want to copy all files with a specific extension from all folders on a hard drive (/mnt/hda1) to an external USB Flash drive (/mnt/uba1).

Identical file names occur in some of these folders so I need to preserve the original path information.

After a lot of struggle (and help from others) I came up with the following program that I key in from a terminal window:

su
mount o ro /dev/hda1 /mnt/hda1
mount o rw /dev/uba1 /mnt/uba1
cd /mnt/hda1
zip r /mnt/uba1/backup.zip i *.htm

This works fine and as a bonus it zips everything.

Is there a simpler way to do it, with or without zipping the results.

The main thing is to preserve the path information .
 
Old 06-27-2005, 07:05 PM   #2
stefan_nicolau
Member
 
Registered: Jun 2005
Location: Canada
Distribution: Debian Etch/Sid, Ubuntu
Posts: 529

Rep: Reputation: 32
Have you looked at all the posts in your own thread (from a few days ago)? Just replace .doc with .htm in the solutions.

http://www.linuxquestions.org/questi...hreadid=337022

The last post contains:
Code:
$ (cd /mnt/hda1; find . -name '*.doc' | xargs tar cf - ) |
> (cd /mnt/udd1; tar xf - )
Another one suggests:
Code:
$ cd /mnt/hda1
$ find . -name '*.doc' |    <----- list all .doc files recursively
> sed 's/^\.\///' |            <----   remove initial ./
> xargs cp --parents --target-directory=/mnt/ubb1
 
Old 06-28-2005, 12:55 PM   #3
dickb
LQ Newbie
 
Registered: Jun 2005
Posts: 15

Original Poster
Rep: Reputation: 0
Question

First, please let me say tahnks for the help so far.
As a Newbie i really appreciate it.

I looked at the reply that suggested thie following code :

$ (cd /mnt/hda1; find . -name '*.doc' | xargs tar cf - ) |
> (cd /mnt/udd1; tar xf - )


I carefully keyed it into a terminal screen but it didn't work.
Perhaps there are some conditions that must be set before I key this code in .
Please not I am writing to /mnt/uba1 indtead of /mnt/udd1

I was careful to make sure the devices were not flagged read only and that the permissions were set to read and write and the devices were mounted.

Here is the eror message I got.:
bash: syntax error near unexpected token '('

I assume the code is correct, so what might be wrong ?

Thanks
 
Old 06-28-2005, 01:21 PM   #4
stefan_nicolau
Member
 
Registered: Jun 2005
Location: Canada
Distribution: Debian Etch/Sid, Ubuntu
Posts: 529

Rep: Reputation: 32
Quote:
I assume the code is correct, so what might be wrong ?
Don't assume, check. The code seems ok to me (but I'm no shell expert).

What did you type exactly? The code contains the shell prompts ($ and >).
 
  


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
backup file *.htm --> * .htm.bak rvoigt Linux - General 4 06-25-2005 05:39 PM
Extension files BC1 Linux - Software 5 12-20-2004 04:41 AM
RedHat 7.2 server hacked and all $HOME/public_html/index.htm files replaced abesharp Linux - Security 5 12-09-2004 04:05 AM
What to do about these files with .new extension? Slovak Slackware 1 11-23-2004 05:50 PM
How program to read files with extension .dat y .cfg files COMTRADE in fedora 1? ivonne Linux - Software 0 11-22-2004 12:42 PM


All times are GMT -5. The time now is 08:27 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