Selecting files in regular intervals from a folder


 
Thread Tools Search this Thread
Top Forums Programming Selecting files in regular intervals from a folder
# 1  
Old 01-30-2012
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,
rpd: wall:
# 2  
Old 01-30-2012
seq is not in my machine .. hence try with the below ..
Code:
i=0
while [ $i -le 2000 ]
do
        [ $i -eq 0 ] && i=1
        echo "cp filename.$i.j /path/to/copy" | sh
        [ $i -eq 1 ] && i=0
        i=$((i+50))
done

# 3  
Old 01-30-2012
Code:
 
echo "" |nawk '{for(i=0;i<=2000;i=i+50){printf("%s\n",i==0?1:i)}}' |while read i
do
 cp filename.$i.* /path/to/new/folder/
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell scripting for moving folder specific files into target directory of that country folder.

I need help to write shell script to copy files from one server to another server. Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Discussion started by: naresh2389
3 Replies

2. UNIX for Dummies Questions & Answers

Bulk load testing in regular intervals

I need to write a script which can send files via sftp communication continously for half an hour or any given duration of time. I have already written a batch file to send multiple file via SFTP. but I need to know how can we set a duration of half an hour through shell script. Can we use sleep... (2 Replies)
Discussion started by: talk1234
2 Replies

3. Shell Programming and Scripting

Compare intervals (columns) from two files (awk, grep, Perl?)

Hi dear users, I need to compare numeric columns in two files. These files have the following structure. K.txt (4 columns) A001 chr21 9805831 9846011 A002 chr21 9806202 9846263 A003 chr21 9887188 9988593 A003 chr21 9887188 ... (2 Replies)
Discussion started by: jcvivar
2 Replies

4. Shell Programming and Scripting

Remove a block of Text at regular intervals

Hello all, I have a text files that consists of blocks of text. Each block of text represents a set of Cartesian coordinates for a molecule. Each block of text starts with a line that has a only a number, which is equal to the total number of atoms in the molecule. After this number is a line... (15 Replies)
Discussion started by: marcozd
15 Replies

5. Shell Programming and Scripting

Bash folder manipulation - selecting/copying specified files

Bash/scripting newbie here - I feel this might be a trivial problem, but I'm not sure how to tackle it. I've got a folder of a year's worth of files, with some random number of files generated every day of the year (but at least one per day). I'm writing a script to automatically grab the file with... (6 Replies)
Discussion started by: WildGooseChased
6 Replies

6. Shell Programming and Scripting

regular expression go into a folder

Hi Everyone, I have two folders /root/jul/a.txt and /root/july/a.txt. I have $month="jul", so use this methold, i only can go into the first folder. is there any way, i can do like $month="jul*", means can go to both folders? becuase the month folder, sometimes is jul, or july, or nov,... (1 Reply)
Discussion started by: jimmy_y
1 Replies

7. Shell Programming and Scripting

Pls Help me out ... I want to check process status at regular intervals of time

I want to check process status at regular interval of time ... so i ha wirtten this BUT its not working when i placed this peace of code in .sh .. please help me out #!/bin/sh w = ps -ef|grep processname | wc - l echo $w if ; then Banner "Proceesname Problem" else Banner " Running... (5 Replies)
Discussion started by: srinivasvandana
5 Replies

8. Programming

performing a task at regular intervals

hi! i m tryin to write a program that will perform a specific tasks after fixed interval of time.say every 1 min. i jus donno how to go abt it.. which functions to use and so on... i wud like to add that i am dont want to use crontab over here. ny lead is appreciated. thanx. (2 Replies)
Discussion started by: mridula
2 Replies

9. Shell Programming and Scripting

mailing myself at regular intervals...

hi all, i wrote a script to mail myself using pine (modified) to keep remind of b'days. #!/bin/bash grep "`date +%D |awk -F/ '{print $2+1, $1+0}'`" dataFile >/home/username/mailme if test -s /home/username/mailme then pine -I '^X,y' -subject "Birthday Remainder" username... (4 Replies)
Discussion started by: timepassman
4 Replies

10. Windows & DOS: Issues & Discussions

Schedule a Batch file to delete files at particular intervals

Hi, I need to write a batch file/shell script that runs at specified intervals daily and deletes specified set of files. Can anyone pls help me with the code. Thanks, Indom. (6 Replies)
Discussion started by: Indom
6 Replies
Login or Register to Ask a Question