LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-11-2007, 08:36 PM   #1
une
Member
 
Registered: May 2004
Location: Australia
Distribution: Mandrake 10, Puppy Linux 2.13
Posts: 201

Rep: Reputation: 30
mkdir & cp in one command?


Say I had a file called
/home/adirectory/text.txt
and I wanted to copy it to a directory that does not yet exist, say
/home/adirectory/newdirectory

prior to executing the command I am looking for, the directory
/home/adirectory
does exist, but
/home/adirectory/newdirectory
does not exist

In one command I want to create the new directory
/home/adirectory/newdirectory
AND copy the file
/home/adirectory/text.txt
to it

I can do it thus
$ mkdir newdirectory;cp test.txt ./newdirectory
by chaining two commands, but I was wondering if it can be done using a single command.
 
Old 03-11-2007, 09:18 PM   #2
vectordrake
Senior Member
 
Registered: Nov 2003
Location: NB,Canada
Distribution: Something alpha or beta, binary or source...
Posts: 2,280
Blog Entries: 4

Rep: Reputation: 47
Try
Code:
mkdir newdirectory && cp test.txt newdirectory/test.txt
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to make a directory with mkdir using the date command. Altheastronut Linux - General 5 06-09-2009 12:14 PM
bash: rpm: command not found && sudo: alien: command not found Java_Code Ubuntu 7 07-27-2006 11:57 PM
About -p Option Of Mkdir Command George2 Linux - Software 4 04-25-2006 06:33 AM
mkdir command digitalgravy Linux - General 5 08-12-2004 01:03 PM
can I use date command with mkdir? ewto Linux - General 6 06-16-2004 08:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration