UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 2nd, 2004, 02:06 PM
Burlhouse Burlhouse is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 4 Burlhouse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old November 2nd, 2004, 08:31 PM
ShizukaWashi ShizukaWashi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Central Florida, U.S.A.
Posts: 77 ShizukaWashi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 56 m 55 sec
Reputation Power: 9
Send a message via AIM to ShizukaWashi Send a message via Yahoo to ShizukaWashi
#!/bin/sh

cp $HOME/*.java $HOME/new
cp $HOME/*.c $HOME/new

chmod 777 $HOME/new/*.c
chmod 777 $HOME/new/*.java

Reply With Quote
  #3  
Old November 3rd, 2004, 01:08 PM
Burlhouse Burlhouse is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 4 Burlhouse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks it works perfectly!!

Reply With Quote
  #4  
Old November 5th, 2004, 07:11 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,200 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Week 1 Day 11 h 47 m 52 sec
Reputation Power: 12
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)

Reply With Quote
  #5  
Old February 7th, 2011, 10:15 PM
Trinimini Trinimini is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2011
Posts: 22 Trinimini User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 29 m 10 sec
Reputation Power: 0
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.

Reply With Quote
  #6  
Old February 8th, 2011, 04:51 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 41 m
Reputation Power: 1485
Your current directory can be referenced by the 'short-cut' of . and your home directory (depending on shell) by ~

So, try:

Code:
cp ~/a* .
__________________
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Copy files from a dir to a new one

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap