LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-10-2007, 06:04 PM   #1
deeptinegi
LQ Newbie
 
Registered: Oct 2007
Posts: 1

Rep: Reputation: 0
Exclamation need help in cp command


i was changing one dos command to linux command, its like:

copy c:\file.mdl c:\data\file_dd.m*

That is the file extension should be the same as the source file(we can have file.mdl, file.mdo..).In linux i did this

cp /folder1/file.mdl /folder/folder1/file_dd.md*
i am getting md* instead of the correct file extension.

Can anybody help me i am just a beginer
 
Old 10-10-2007, 06:31 PM   #2
The_JinJ
Member
 
Registered: Apr 2004
Location: Scotland
Distribution: Suse, OpenWRT
Posts: 299

Rep: Reputation: 30
This will work
cp /folder1/file.md? /folder/folder1/

or for anything with .md* extension even more than 3 chars

cp /folder1/file.md* /folder/folder1/
 
Old 10-10-2007, 06:35 PM   #3
AceofSpades19
Senior Member
 
Registered: Feb 2007
Location: Chilliwack,BC.Canada
Distribution: Slackware64 -current
Posts: 2,079

Rep: Reputation: 58
its because that copies file.mdl to /folderfolder/file_dd.md, I think you want cp /folder/file.md* /folder/folder1/ which copies any files in /folder with any extension beginning with md to /folder/folder1
 
Old 10-10-2007, 06:49 PM   #4
rsashok
Member
 
Registered: Nov 2006
Location: USA, CA
Distribution: RedHat, Debian
Posts: 202

Rep: Reputation: 31
Try this bash script, lets call it 'kacp' (kick ass copy):

Code:
#!/bin/bash

if [ $# -eq 0 ]; then
   echo "Usage: `basename $0` file.name"
   exit 0
fi 

filename=$1
ext=${filename##*.}
base=${filename%%.*}

echo
echo Copying file: /folder1/$1  to /folder1/"$base"_dd."$ext"

cp /folder1/$1 /folder1/"$base"_dd."$ext"
Then you should execute it as:

Code:
kacp file.mdl
You need to change source and destination paths in the script from 'folder1' to a real name. But you got the idea....
 
  


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
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 02:23 AM
Why after start of a command the invitation for input next command has not appeared. ukrainet Linux - General 3 06-24-2005 08:16 AM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 07:14 PM
Command to display whole filestructure hierarchy f/ command line? mjewell Linux - Newbie 10 01-19-2004 10:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:10 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