Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to copy all the files that I have in the system with extension sol to the specific folder can you please help me. I tried sudo cp / *.sol ~/SOL/ but it doesn't work

UPDATED:

I tried to follow the first answer, and that's what I got:

root@johntheripper-PORTEGE-Z835:~# find / -name *.sol | wc -l
61
root@johntheripper-PORTEGE-Z835:~# find / -type f -name '*.sol' -exec cp {} ~/SOL \;
...
...
...
root@johntheripper-PORTEGE-Z835:~# find ~/SOL -name *.sol | wc -l
26

As you can see 26 out of 61 file was copied, please help me to copy the rest.

share|improve this question
2  
Probably its due to duplicate names.(man files of same name in different directories) –  user61928 Oct 16 '12 at 14:37
    
this is a good point, do you know any way to kinda say in linux: 'if there is a file system.sol, create system1.sol'? –  Vor Oct 16 '12 at 15:34

3 Answers 3

up vote 2 down vote accepted

There's a bash script to copy files with specific extension in this link.

There's also an answer on StackOverflow, I haven't tested it yet, but here it is:

find / -type f -name '*.sol' -exec cp '{}' ~/SOL \;

EDIT: As phoibos suggested, I changed the answer adding '' in the code.

share|improve this answer
    
Thank you very much –  Vor Oct 15 '12 at 23:32
    
Actually, this statement copied some of the files but not all of them. –  Vor Oct 16 '12 at 0:30
    
Sorry, I didn't test the script, I'll try to find another one or make one myself. –  Evandro Silva Oct 16 '12 at 12:10
1  
It probably didn't work for files with spaces in its name. Enclose the {} with ': find / -type f -name '*.sol' -exec cp '{}' ~/SOL \; –  phoibos Oct 16 '12 at 14:30
    
Thanks, I'll try it. –  Evandro Silva Oct 16 '12 at 14:33

I usually use Midnight Commander for this. You can install it using

sudo apt-get install mc

Midnight Commander

To find all files with a particular extension, choose Command -> Find File (Esc-?), enter your search criteria, when the search finishes click [Panelize]. All files found will be displayed in a panel from where you can review and copy them.

The explanation is a bit long but believe me it's easier than remembering the syntax of the find command :)

share|improve this answer
    
Thank you very much! This is very nice program –  Vor Oct 15 '12 at 23:33

First change to root

sudo -s

change directory to /

cd /

Now enjoy

cp $(locate *.sol) /path-to-directory

PS: IF the count is less it may be due to duplicate files,You can check the output

share|improve this answer
    
Nice and short answer! But how to rename duplicates and still copy them? –  Vor Oct 16 '12 at 15:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.