LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 01-29-2012, 11:59 PM   #1
rpd25
LQ Newbie
 
Registered: Dec 2011
Posts: 12

Rep: Reputation: Disabled
Selecting files in regular intervals from a folder


Hi,

I need your expertise in selecting files from a folder.

I have files named with convention: filename.i.j
where j is an interger from 1 to 16, for each i which is an integer from 1 to 2000.

I would like to select the files with i in regular interval of 50 like
filename.1.j, filename.50.j, filename.100.j,...

How to write a script to select files in regular intervals and copy them in other directory?

Thanks,
Rakesh
 
Old 01-30-2012, 12:15 AM   #2
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 617

Rep: Reputation: 359Reputation: 359Reputation: 359Reputation: 359
Hi.

Code:
for i in 1 `seq 50 50 1000`; do echo cp filename.$i.* target; done
Remove `echo' to actually copy files.

Or, if you use recent bash, try
Code:
$ echo cp  filename.{1,{50..2000..50}}.* target
 
Old 01-30-2012, 12:52 AM   #3
rpd25
LQ Newbie
 
Registered: Dec 2011
Posts: 12

Original Poster
Rep: Reputation: Disabled
Thank you for the quick reply.

I used the command to transfer files in different clusters using scp command

scp -rp username@remotehost.edu:/DirectoryLocation/udisp.{0,{100..10000..100}}.* .

The files are transferred, however after every 100'th files, it asks me the password to transfer files.
This is very irritating. Is there any option to grant transfer permission once?

One more thing, how to transfer multiple files udisp.i.j and vdisp.i.j (in interval of 100's) at once using scp?

Thanks,
Rakesh
 
Old 01-30-2012, 02:13 AM   #4
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 617

Rep: Reputation: 359Reputation: 359Reputation: 359Reputation: 359
Hi.

I can not reproduce the multiple authentication issue yet. In my tests authentication takes place ony once, then scp copies multiple files.
Man page mentions the `-B' flag to scp
Quote:
-B Selects batch mode (prevents asking for passwords or passphrases).
but I don't think it will help.

So, can you provide some more info, e.g. run scp in verbose mode (-v) and post the log here?

To transfer udisp and vdisp try something like
Code:
scp -rp username@remotehost.edu:/DirectoryLocation/[udisp,vdisp].{0,{100..10000..100}}.* .
 
Old 01-30-2012, 04:39 AM   #5
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
What about using tar
Code:
ssh username@remotehost.edu \
"cd /DirectoryLocation; tar cf - [udisp,vdisp].{0,{100..10000..100}}.*" |\
tar xvf -
 
  


Reply

Tags
file chooser, select


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
selecting digits from regular expression vjramana Programming 2 09-05-2011 06:02 AM
How do I schedule a userspace application to run at regular intervals AustinMarton Linux - Software 4 08-05-2009 12:22 AM
mv and regular expressions, mv file(_*).foo folder jmcejuela Linux - Newbie 3 04-01-2009 03:35 PM
Splitting audio files at specific time intervals quickfix Linux - Software 2 08-26-2005 07:18 AM
mailing myself at regular intervals... piyushiitk Programming 4 08-21-2005 10:26 AM


All times are GMT -5. The time now is 06:38 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration