LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-16-2011, 11:20 AM   #1
alexandrenpl
LQ Newbie
 
Registered: Feb 2011
Posts: 3

Rep: Reputation: 0
selecting files with scripts


Hi everybody!

I have been searching for an answer for 2 days in internet but i'm still unable to do what I want.

I have tons of files named in this way.

[L H]P[1-10]-[ec et ct][1 5 10].png

So for example, I have files named:

LP4-ec5.png
HP9-ct10.png
LP1-et1.png
LP10-ct10.png

and so on...

My idea was to create an interacting script in which I choose the files I want to view in a separate folder.

For example:

I want files starting with L or H, but the 3, 4 and 7, all ct and the last option number 1 (example).

So the files copied were:

LP3-ct1.png
HP3-ct1.png
LP4-ct1.png
HP4-ct1.png
LP7-ct1.png
HP7-ct1.png

Or other options...

Do you have any ideas on how to implement this?

Many thanks to you all!
 
Old 02-16-2011, 11:31 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Hi, welcome to LQ!

Not sure I fully understood, but is this what you're after... ?
Code:
cp {L,H}P{3,4,7}-ct1.png <target_dir>/.


Cheers,
Tink
 
Old 02-16-2011, 11:37 AM   #3
alexandrenpl
LQ Newbie
 
Registered: Feb 2011
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Tinkster View Post
Hi, welcome to LQ!
Thank you!

Quote:
Originally Posted by Tinkster View Post
Not sure I fully understood, but is this what you're after... ?
Code:
cp {L,H}P{3,4,7}-ct1.png <target_dir>/.
Yes, that'll do the trick!
I was trying to use sed/grep/awk and it was a mess.

Thank you again!
 
  


Reply



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
Selecting files with ^M in the filename chengbao1 Linux - General 4 10-24-2010 03:59 PM
selecting all files to mv chisholm Linux - Newbie 2 11-09-2008 03:40 PM
selecting a range of files.... mjh Programming 0 03-12-2008 09:02 AM
XMMS not selecting files suro Fedora 1 03-26-2005 03:25 PM
selecting specific files slack66 Linux - Newbie 1 02-14-2004 07:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:40 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
Open Source Consulting | Domain Registration