LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-11-2010, 08:45 AM   #1
DoME69
Member
 
Registered: Jan 2008
Posts: 164

Rep: Reputation: 15
There is any way to copy with -p option all *.v files?


Hi...


how can i copy by script or command files with *.v suffix by "-p" option ?

Example:

kuku.ggg
kuku.dd
kuku.v
kuku.vb

only if i try to copy kuku.v by default cp -p will done.
 
Old 04-11-2010, 09:06 AM   #2
LouRobytes
Member
 
Registered: Mar 2010
Location: Nova Scotia, Canada
Distribution: Ubuntu & Fedora
Posts: 189

Rep: Reputation: 44
Code:
cp -p path/ *.v
Substitute path with location.

Works for me.

Cheers, Lou
 
Old 04-11-2010, 09:12 AM   #3
DoME69
Member
 
Registered: Jan 2008
Posts: 164

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by LouRobytes View Post
Code:
cp -p path/ *.v
Substitute path with location.

Works for me.

Cheers, Lou
sorry i have a missing details.

i want allways use "cp file location"
but if file cotain *.v...

cp file location = cp -p file location.

Thanks
 
Old 04-11-2010, 09:42 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Are you saying that you want to use the -p flag only if the file contains ".v" extension?

How about this:
Code:
find <path> -name "*.v" -exec cp -p {} newname \;
 
Old 04-11-2010, 10:21 AM   #5
DoME69
Member
 
Registered: Jan 2008
Posts: 164

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by pixellany View Post
Are you saying that you want to use the -p flag only if the file contains ".v" extension?

How about this:
Code:
find <path> -name "*.v" -exec cp -p {} newname \;
seems o.k but how can i set that if it doesn't equal to *.v that use cp without "-p" option?

Thnak
 
Old 04-11-2010, 10:30 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Code:
for filename in $(ls -lR); do
     if [ <test for .v> ]; then cp -p <details>
     else cp <details>
     fi
done
Insert the appropriate code inside the <...>
 
Old 04-11-2010, 10:33 AM   #7
DoME69
Member
 
Registered: Jan 2008
Posts: 164

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by pixellany View Post
Code:
for filename in $(ls -lR); do
     if [ <test for .v> ]; then cp -p <details>
     else cp <details>
     fi
done
Insert the appropriate code inside the <...>
I'm using cshell.
could you write it on cshell?

sorry if its bother you.
 
Old 04-11-2010, 11:34 AM   #8
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by DoME69 View Post
I'm using cshell.
could you write it on cshell?

sorry if its bother you.
I was only trying to show the approach---basically to look at one file at time, determine if it has the .v extension, and then take the desired action.

I'm sure that "cshell" has similar syntax--check your documentation.

Last edited by pixellany; 04-11-2010 at 07:11 PM. Reason: typo
 
  


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
How to enable copy paste option between Vista (host) and Fedora (Guest) on VMware Maggidis Linux - Virtualization and Cloud 1 02-28-2010 10:17 AM
Creating a script to move or copy files into multiple directories below the files matthes138 Linux - Newbie 5 08-25-2009 05:57 PM
cp (copy) option gautam143 Linux - Software 4 07-30-2008 09:44 AM
in copy files or ls files the command want to invert select some files how to?? hocheetiong Linux - Newbie 3 06-27-2008 07:32 AM
Command to copy files/folders but skip bad/corrupt files?? leemoreau Linux - Newbie 2 04-02-2007 03:27 PM


All times are GMT -5. The time now is 10:52 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration