Welcome to the North American Subaru Impreza Owners Club Friday July 25, 2014
Home Forums WikiNASIOC Products Store Modifications Upgrade Garage
NASIOC
Here you can view your subscribed threads, work with private messages and edit your profile and preferences Home Registration is free! Visit the NASIOC Store NASIOC Rules Search Find other members Frequently Asked Questions Calendar Archive NASIOC Upgrade Garage Logout
Go Back   NASIOC > NASIOC Miscellaneous > Off-Topic

Welcome to NASIOC - The world's largest online community for Subaru enthusiasts!
Welcome to the NASIOC.com Subaru forum.

You are currently viewing our forum as a guest, which gives you limited access to view most discussions and access our other features. By joining our community, free of charge, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is free, fast and simple, so please join our community today!

If you have any problems with the registration process or your account login, please contact us.
* Registered users of the site do not see these ads.
Reply
 
Thread Tools Display Modes
Old 04-05-2004, 08:56 PM   #1
Kinsbane
Scooby Specialist
 
Member#: 15679
Join Date: Feb 2002
Chapter/Region: SCIC
Location: GPSW - UFQC
Default Need help with some UNIX commands.

So, I need to copy all of a directory's files into a directory of another name.

I tried cp -r dir1 dir2, but it put dir1 as a sub-directory of dir2. I don't want that.
* Registered users of the site do not see these ads.
Kinsbane is offline   Reply With Quote
Old 04-05-2004, 08:59 PM   #2
jaywat513
Scooby Newbie
 
Member#: 23736
Join Date: Aug 2002
Chapter/Region: MWSOC
Location: Cincinnati
Vehicle:
2002 WRX
Platinum Silver

Default

go into dir1 cp -r *.* dir2

it has been a while since I used a nix.

edit: or maybe even cp -r dir1/* dir2

there are a ton of ways to do it..
jaywat513 is offline   Reply With Quote
Old 04-05-2004, 09:02 PM   #3
Skyline
Scooby Specialist
 
Member#: 6074
Join Date: Apr 2001
Location: New Jersey
Vehicle:
2002 Impreza WRX
Sedona Red Pearl

Default

Your dir2 can't exist already. If dir2 does not exist, dir2 will be a copy of dir1. If dir2 already exists, the dir1 copy will go inside dir2.
Skyline is offline   Reply With Quote
Old 04-05-2004, 09:02 PM   #4
Kinsbane
Scooby Specialist
 
Member#: 15679
Join Date: Feb 2002
Chapter/Region: SCIC
Location: GPSW - UFQC
Default

Quote:
Originally posted by jaywat513
go into dir1 cp -r *.* dir2

it has been a while since I used a nix.

edit: or maybe even cp -r dir1/* dir2

there are a ton of ways to do it..
which would you say is the better way to do it? -r *.* or -r dir1/* ?
Kinsbane is offline   Reply With Quote
Old 04-05-2004, 09:03 PM   #5
Skyline
Scooby Specialist
 
Member#: 6074
Join Date: Apr 2001
Location: New Jersey
Vehicle:
2002 Impreza WRX
Sedona Red Pearl

Default

Quote:
Originally posted by jaywat513
go into dir1 cp -r *.* dir2
Save the "*.*" for DOS. It'll only cause you headaches in Unix.
Skyline is offline   Reply With Quote
Old 04-05-2004, 09:08 PM   #6
aod
NASIOC Supporter
 
Member#: 7121
Join Date: Jun 2001
Chapter/Region: MWSOC
Location: How about CAVE EXPLORER
Default

Yes, *.* is for lam0rz in *nix land.
aod is offline   Reply With Quote
Old 04-05-2004, 09:09 PM   #7
Kinsbane
Scooby Specialist
 
Member#: 15679
Join Date: Feb 2002
Chapter/Region: SCIC
Location: GPSW - UFQC
Default

so its -r dir1/* then ?
Kinsbane is offline   Reply With Quote
Old 04-05-2004, 09:12 PM   #8
jaywat513
Scooby Newbie
 
Member#: 23736
Join Date: Aug 2002
Chapter/Region: MWSOC
Location: Cincinnati
Vehicle:
2002 WRX
Platinum Silver

Default

Quote:
Originally posted by aod
Yes, *.* is for lam0rz in *nix land.
yeah, like I said it has been a while
jaywat513 is offline   Reply With Quote
Old 04-05-2004, 09:14 PM   #9
Skyline
Scooby Specialist
 
Member#: 6074
Join Date: Apr 2001
Location: New Jersey
Vehicle:
2002 Impreza WRX
Sedona Red Pearl

Default

If dir2 already exists, "cp -r dir1/* dir2" will copy the contents of dir1 into the dir2 directory.

If dir2 does not already exist (what you really should be doing), then "cp -r dir1 dir2" will make dir2 the copy.
Skyline is offline   Reply With Quote
Old 04-05-2004, 11:51 PM   #10
aod
NASIOC Supporter
 
Member#: 7121
Join Date: Jun 2001
Chapter/Region: MWSOC
Location: How about CAVE EXPLORER
Default

Quote:
Originally posted by jaywat513
yeah, like I said it has been a while
Oops. I didn't mean you specifically. I used to get a kick watching management types try to learn how to get around in *nix at one of my jobs. Every single one of them would type "dir *.*" as their very first *nix command. Of course, sometimes "dir" is aliased, but still. Then when they'd learn that "ls" was the correct command, then came the "ls *.*", etc.

Kinsbane: In *nix, it is not required for a filename to have a . in it like it is in DOS. *.* in *nix matches everything that has a . in the filename. In fact, I always thought it was generally a poor idea to do *.* in DOS too since * will match all files in DOS as well.

Also, Skyline is correct on the methods. The -r flag in cp means "recursive". When in doubt about a *nix command, check out the manual page for it. Type "man cp" at the prompt to pull up a manual page for the cp command.

Hope that helps.
aod is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I need help with some track/autoX research please… J Ritt Motorsports 16 10-13-2003 02:38 AM
All you chemistry majors or people that know chemistry I need help with some problems Meat-Head-h Off-Topic 1 10-06-2003 08:45 PM
Need help with some part numbers, ASAP foolio Interior & Exterior Modification 9 12-11-2002 02:12 PM
Need help with some speaker sizes crxtls2 New England Impreza Club Forum -- NESIC 1 06-23-2002 04:30 PM
Need help with some items I can't find. obyone Mid West Subaru Owners Club Forum -- MWSOC 2 06-02-2002 01:39 AM


All times are GMT -4. The time now is 12:11 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Powered by Searchlight © 2014 Axivo Inc.
Copyright ©1999 - 2014, North American Subaru Impreza Owners Club, Inc.