Hi, im taking an entry Unix class, and as part of my lab assignment I have to copy all files in the /home/david/lab3 directory that have the file extension .save to your lab3/temp directory. I'm having trouble getting the grep to do anything worth while
and havnt gotten it to work yet. Am I using the right context? I really am at a loss here. Also, when I try to run "grep '.save' in the /home/david/lab3 directory i dont get any output, and i have to ctrl+d to get back to a prompt. Any help would be appreciated, I have to finish this lab by 6:30pm EST.
I get an error:
[user113@vbitblnx1 lab3]$ ls
my.names mynames.save names names.020807 names1 names.sav names.save pass
[user113@vbitblnx1 lab3]$ cp 'ls /home/david/lab3/*.save' /home/user113/temp
cp: cannot stat `ls /home/david/lab3/*.save': No such file or directory
---------- Post updated at 02:29 PM ---------- Previous update was at 02:23 PM ----------
Okay i think i got it
pwd
/home/david/lab3
cp *.save /home/user113/lab3 works for me
grep matches regular expressions. The regexp for a string (filename), followed by a dot, followed by another string (extension) would be something like: grep '.*\.save$'
However you don't need to use grep at all; It can be done with a single command, using wildcards:
cp /your/path/*.save /destination
EDIT: Oh, well... my reply was too late. Anyway, glad you figured it out by yourself.