copy probs


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers copy probs
# 1  
Old 11-16-2004
copy probs

need help....just wanna copy all files with no extensions but with tree-informations to one dir

first I make a new directory with all foldertrees...like

find / -name "*" -type d >a1
sed -e 's/^/new/g' <a1 >b1
mkdir -p `cat a1`

then I wanna copy all specific files with no extensions(!)..like

cd /temp
find / -name "*" -type f >a2
grep -v "\.TMP$" a2 >b2
grep -v "\.Z$" b2 >a2
grep -v "\.gz$" a2 >b2
.....and so on, then...

sed -e 's/^/new/g' <b2 >c2
mv c2 /
cd
for i in `cat b2`
do
cp -pf $i `cat c2`
done
....
this loop isn't working.

[no such directory....but the directory is there!]

also it is possible to make easily....
cp /dasdöadk/fsldfjsdfö/sdfsdf (is a file!) /dasddsss/reww/sdfs (also a file!) ...but the loop can't it .

but cp -pf $i /temp works - but without the subfolders.....

Smilie

how to solve this ?

--------------------------

to say it more easier....just like copy files by a loop, for example...users/123/abc (is a file) to new/users/123/abc (also file)

Last edited by svennie; 11-16-2004 at 10:45 AM..
# 2  
Old 11-16-2004
Probably the easiest way to do this would be to cp -r the source to the destination then rm -r *.* the destination to remove everything with an extension.
# 3  
Old 11-16-2004
I thought of a real solution........

by the way I wanna get the loop working. not the files - the loop is what I'm interesting in. Smilie

in file a there are f.e. the files:

users/tmp/1212
users/tmp/232121
users/hhsfs/234q2q3
ada/qeqweq/rwerwe3

and now I just wanna transfer them to like in file b:

new/users/tmp/1212
new/users/tmp/232121
new/users/hhsfs/234q2q3
new/ada/qeqweq/rwerwe3

...that's all.
# 4  
Old 11-16-2004
Here is one to find files with no extension in the current directory
Code:
#!/bin/ksh
for file in *
do
    file_ext=${file#*.*}
    if [ $file_ext = $file ]  
    then
        echo "no extension = $file"
    else
        echo "filename = $file extension= $file_ext"
    fi
done
exit

# 5  
Old 11-16-2004
niceSmilie ....but I've already found them. just only copy them....
# 6  
Old 11-16-2004
If I had a directory, say
/tmp/foo

And within /tmp/foo I had some files, some with extensions, some without.

Within /tmp/foo, I've got a directory /tmp/foo/new. I want to copy all files without an extension from /tmp/foo to /tmp/foo/new, creating directories as I go.

I'd probably do something along the lines of
Code:
$ cd /tmp/foo
$ DEST=./new
$ find . -print | grep -v "^[.].*[.].*$" | grep -v "^[.]$" |\
> grep -v "$DEST" | cpio -pdv $DEST

Sticking to the loop requirement does, IMHO, make the whole thing unecessarily complicated, and involves far too many temp files.

Cheers
ZB
# 7  
Old 11-16-2004
find . -print | grep -v "^[.].*[.].*$" | grep -v "^[.]$" |\

...there you take off all extensions, what about the [] and why print (..never used..) ? why is there a backslash at the end of the line?

> grep -v "$DEST" | cpio -pdv $DEST

...just don't understand really. why grepping out $DEST (./new)and what does cpio do - is it not like a compression method?

..the idea with | is very nice. but what about the subfolder information? f.e. if the files are like...

users/abc/ff (file)
users/gef/geh (file)
fun/much/124 (file)

- is there a chance of

new/users/abc/ff
new/users/gef/geh
new/fun/much/124

- not like....

new/ff
new/geh
new/124?
 
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