copy probs


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers copy probs
# 8  
Old 11-16-2004
I'll take my command apart pipeline by pipeline

find . -print
The finds all files in the current directory and any subdirectories. I add -print to ensure that the relative path is passed to the stdin of the next command, which is...

grep -v "^[.].*[.].*$"
This, as you say, gets rid of any files that have an extension

grep -v "^[.]$"
This removes "." - the current directory

\ is the line-continuation character

grep -v "$DEST"
This removes the destination directory from the input, no use trying to copy ./new to ./new/new is there?!

cpio -pdv $DEST
Copy in/out in pass through mode.

man cpio

All subfolders will be copied.
i.e.
/tmp/foo/some/folder/with/a/file
will be copied to
/tmp/foo/new/some/folder/with/a/file

Preserving the entire tree.

Cheers
ZB
# 9  
Old 11-17-2004
find .
find / -> is clear....

print -> just don't understand anyway..

grep -> is clear..

\ -> line continue is clear..

cpio -> copy file archives in and out; duplicate directory trees
cpio -p dest -> copy pass modus from one to another directory
cpio -d -> create directories as needed (must the dirs not exist?)
cpio -v -> print a list of file names as they are processed

for example, I just wanna copy all files without any extension to one dir with the subfolders - all files are in different folders but the subfolders are like same named, f.e. pics:

VAR=/pics
DEST=/new
cd
find / -type f | grep "$VAR" | grep -v "^[.].*[.].*$" | \
cpio -pdv $DEST

now any files without an extension from any subfolder called pics should be transfered to the folder new, not!?

like....

new/users/123/pics/qweq
new/users/3241/qqqqw/pics/daqwwe
new/var/.images/pics/sadas

thx...
# 10  
Old 11-17-2004
Yes, that should work. Test it and see - works for me.

Cheers
ZB
# 11  
Old 11-18-2004
very nice ... but doesn't work perfectly.

grep -v "^[.].*[.].*$" didn't make it - so I've to go extension by enxtension, like

grep -v "\.TMP$"|\
grep -v "\.Z$" b2|\
grep -v "\.gz$"|\
....etc.

is there missing the backslash in "^[.].*[.].*$"?

by the way, I've got some files where I've got to rename them because of the ":" in its filename.

grep -v ":" works - but how to change ":" to "_" ?

I've read it in the forum, but don't find it anymore.

only sth. like append an extension.

for file in `cat file`
do
mv ${file} ${file}.tmp
done
..
is it possible to make it working for me and the ":" -> "_" prob?

thx again...
Smilie
# 12  
Old 11-18-2004
The grep works for me. Could it be because you are not using -print with find (which gives full path starting at the current directory ".")?

Grepping out specific extensions is probably easiest anyway, because of the fact that if you have a file called "myfile_version2.1", it will treat that as having an extension (.1).

To rename files, do something like this with "tr"

file="my:file"
newfile=`echo $file | tr ':' '_'`
mv $file $newfile

EDIT: Looking at your code, the reason it doesn't work it because your find starts at "/", not "." This is easy to remedy and something like
grep -v "^[^.]*[.].*$"
should do it.

Cheers
ZB
# 13  
Old 11-18-2004
thx a lot...I've found the side https://www.unix.com/showthread.php?s...0&highlight=mv

there is an equal solution done by sed.

now I understand what you mean by using -print Smilie

"^[^.]*[.].*$" - looks a litte bit too strange for my experiences...

anyway I think now I can solve it on my own.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Virtualization and Cloud Computing

Connection probs in virt. OSolaris in Qemu under Ubuntu

Hi, I'm trying to do this: Set up OpenSolaris with Qemu (Ubuntu is hostOS). I was able to get it up and running and I have installed it on my .img. But now I need internet connection. On my Ubuntu host I did this: #brctl addbr br0 #tunctl #brctl addif br0 wlan0 #brctl addif br0 tap0... (1 Reply)
Discussion started by: fisfia
1 Replies

2. UNIX for Dummies Questions & Answers

What is in-core copy and disk-copy of i-node table?

I have found a question from the exercises of my study mat. The question is "Why are there a in-core copy and a disk-copy of i-node block and super block?" If any one know the proper answer then please send me..... (1 Reply)
Discussion started by: dearanik
1 Replies

3. UNIX for Dummies Questions & Answers

probs executing crontab script

Hi everyone In an existing crontab script for the root user, I've added 5 new lines of code, however for some unknown reason, these lines of code were not executed. Here is what I did 30 0 * * * ./usr/people/atlab/jamesgoh/disk_reader/disk_reporter /picnic 30 0 * * *... (6 Replies)
Discussion started by: JamesGoh
6 Replies

4. Programming

probs adding linker option in g++

Hi all Im trying to compile a C++ program, however Im having issues trying to link a particular library to the compiling and linking statement. Here is what Im doing g++ mips4 -std=c++98 -g disk_reporter.cpp -o disk_reporter If I do this alone, the linker complains that library... (2 Replies)
Discussion started by: JamesGoh
2 Replies

5. Programming

probs compiling with gcc + lpthread

Im trying to write a program atm which uses mutexes to control thread access to a certain code section ( the critical section). However, whenever I compile the code using gcc I get the following message from gcc Unresolved text symbol "pthread_mutex_lock" Unresolved text symbol... (1 Reply)
Discussion started by: JamesGoh
1 Replies

6. UNIX for Dummies Questions & Answers

hi probs with rm command

hi guys... i m using rm *.zip or rm -rf *.zip while removing from a server path recursively, i m getting "Remove directory operation failed." if i use rm* .zip i m getting as invalid command and none of the files are removed.. please help where m i wrong when i execute the... (13 Replies)
Discussion started by: madhu_aqua14
13 Replies

7. UNIX for Dummies Questions & Answers

Dell - Installing SCO Openserver 6.0 probs with ADAPTEC 1210SA

Trying to install Sco OSR 6.0 on Dell Optiplex with SERIAL ATA ADADPTEC 1210SA controller. Sco says its sipported by the AACRAID driver but on installation its says that it doesnt recognise the partitions In the middle of re-formatting at the moment - just wondered if anyone had anu... (0 Replies)
Discussion started by: farmacy
0 Replies

8. Solaris

More SSH probs ...

Server 1 SSH Version Sun_SSH_1.0 Server 2 OpenSSH_3.8.1p1 Server 3 OpenSSH_3.8p1 I created the rsa keys on server1. Public and private. I copied the id_rsa.pub file to server2 and server3 and appended this to the authorized_keys file in the .ssh directory on both. (All servers using the root... (2 Replies)
Discussion started by: frustrated1
2 Replies

9. Shell Programming and Scripting

probs compiling lex

this is my lex file ------------ test.l %% printf("%c",yytext+'a'-'A');.ECHO; how do i compile it $ lex test.l cc lex.yy.c -o test -ll <------| | if this is correct do i add this line--------| @the command line or does it... (0 Replies)
Discussion started by: sinner
0 Replies

10. UNIX for Dummies Questions & Answers

oracle probs on HPUX11

Hi all we r using hpUX11.00 9000 sever as oracle 8i db server... But the problem is we have 4 instances of dbs but upto my knowledge there are only to ports available for TNS listen... how can i configure or get wht ever it may be the other two ports for tns listener......... ... (2 Replies)
Discussion started by: Prafulla
2 Replies
Login or Register to Ask a Question