Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 03-11-2007, 09:36 PM   #1
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
and I wanted to copy it to a directory that does not yet exist, say

prior to executing the command I am looking for, the directory
does exist, but
does not exist

In one command I want to create the new directory
AND copy the file
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, 10:18 PM   #2
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
mkdir newdirectory && cp test.txt newdirectory/test.txt


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 01:14 PM
bash: rpm: command not found && sudo: alien: command not found Java_Code Ubuntu 7 07-28-2006 12:57 AM
About -p Option Of Mkdir Command George2 Linux - Software 4 04-25-2006 07:33 AM
mkdir command digitalgravy Linux - General 5 08-12-2004 02:03 PM
can I use date command with mkdir? ewto Linux - General 6 06-16-2004 09:47 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:16 PM.

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