November 2nd, 2004, 02:06 PM
Copy files from a dir to a new one
I need to write a Bourne shell script to do the following:
(i)Copy a *.java and *.c files in /Home/MyHomeDir to a directory called /Home/MyHomeDir/NewDir
(ii)Make all the files executable and readable by everyone
November 2nd, 2004, 08:31 PM
cp $HOME/*.java $HOME/new
cp $HOME/*.c $HOME/new
chmod 777 $HOME/new/*.c
chmod 777 $HOME/new/*.java
November 3rd, 2004, 01:08 PM
Thanks it works perfectly!!
November 5th, 2004, 07:11 AM
this perfecty && accidentally work
in unix, i would say
cd #this bingt me to home
[ -d ../new ] || mkdir ../new || exit 1
cp *.java *.c ../new
#he said: executable and readable by everyone
chmod 755 ../new/*.java ../new/*.c
ALL other is hazard (but working IN YOUR ENVIRONMENT)
February 7th, 2011, 10:15 PM
I'm having a similar problem with copying files from one directory to another. It's part of a lab I need to do for school. Now ordinarily, I wouldn't go online looking for an answer to one question, but I am unable to proceed unless I can get past this question. So here it is:
"Enter a command to copy all files in your home directory beginning with the
letter 'a' to the current directory."
For this, I must assume that I am not in my home directory. Also, the question does not specify which directory I'm in- and no, I cannot issue a pwd command to find out where I am.
I've tried 'cp /home/dreynolds5/a*'; 'cp /home/dreynolds5/[a]*'; 'cp ~dreynolds5/a*'; 'cp ~dreynolds5[a]*'; 'cp ~/a*' and 'cp ~/[a]*'
As I'm sure you've all figured out, none of those worked. Any sort of help is appreciated.
February 8th, 2011, 04:51 AM
Your current directory can be referenced by the 'short-cut' of . and your home directory (depending on shell) by ~
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc