Process some limited file from a directory


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Process some limited file from a directory
# 1  
Old 05-17-2010
Process some limited file from a directory

Hi,
I am having a directory, Having some thousand of file i want to process mean some limited files (say 6 number of files ) not the all files at a time to do that operation on them(after finish operation i'll remove and take that file back up ). Can i achieve this thing using set and shift operator or any possible way to get with looping .

Thanks
Posix

---------- Post updated at 18:34 ---------- Previous update was at 12:32 ----------

Any ways i got this method it works but need to achieve same thing with set and shift also can i make use of argc & argv over here.
Code:
s_f=/source/path/to/file             
d_f=/destination/path/to/file         
let var=1                                                                       
for file in $s_f/*                                                              
do                                                                              
if [ $var -le 6 ];then                                                          
cp "$file" $d_f                                                                 
rm  -f $file                                                                    
let var=$var+1                                                                  
fi                                                                              
done

Different approaches also helpful for application.
Thanks
Posix
# 2  
Old 05-17-2010
That's what xargs is for:
Code:
% touch file{01..15}
% printf '%s\n' *  | xargs -n6 echo 6 at most:
6 at most: file01 file02 file03 file04 file05 file06
6 at most: file07 file08 file09 file10 file11 file12
6 at most: file13 file14 file15

Assuming no pathological characters in the filenames.
# 3  
Old 05-18-2010
thanks radoulov, got a new idea.
Form your response Smilie. But it processed all the file in one run , rather it have to take 3 run to do all files to process.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Monitoring processes in parallel and process log file after process exits

I am writing a script to kick off a process to gather logs on multiple nodes in parallel using "&". These processes create individual log files. Which I would like to filter and convert in CSV format after they are complete. I am facing following issues: 1. Monitor all Processes parallelly.... (5 Replies)
Discussion started by: shunya
5 Replies

2. Shell Programming and Scripting

Script to process file from a directory and grep the required content and print

Hi All, below script reads the perticular files from the directory. Am trying to fetch status and print them in the required format. It needs to read line and search for string "Passed/Failed" and print them under correct sub header. script : BASE_DIR=/tmp/test/REPORT/CollectReport #... (16 Replies)
Discussion started by: Optimus81
16 Replies

3. Shell Programming and Scripting

Copy and Paste Columns in a Tab-Limited Text file

I have this text file with a very large number of columns (10,000+) and I want to move the first column to the position of the six column so that the text file looks like this: Before cutting and pasting ID Family Mother Father Trait Phenotype aaa bbb ... (5 Replies)
Discussion started by: evelibertine
5 Replies

4. Shell Programming and Scripting

to parse (or grep) a number from a datafile and write it to tab limited file

Hi All, I have a folder that contain 100's of subfolders namely: Main folder -> GHFG - Subfoders ->10 100 234 102 345 .. .. ... (2 Replies)
Discussion started by: Lucky Ali
2 Replies

5. Solaris

User with limited access to one directory

is there a way to create a user and limit him to read,write and execute only in one direcotry. the directory is already exsist and it belongs to dba group. i would like to make this user can't even cd to another directory or even if he can he cant do anything in the other directories. if... (7 Replies)
Discussion started by: q8devilish
7 Replies

6. HP-UX

how could I get process working directory

how could I use c program to get HP UX process working directory (1 Reply)
Discussion started by: alert0919
1 Replies

7. Shell Programming and Scripting

Copy Limited rows from one file to another

Hi, The file contains 1000 of rows can you please let me know How to copy 1-10 and 30-40 rows from one file to another. thanks :) (3 Replies)
Discussion started by: ravi214u
3 Replies

8. UNIX for Dummies Questions & Answers

MAX file size limited to 2GB

Hi All, We are running HP rp7400 box with hpux 11iv1. Recently, we changed 3 kernel parameters a) msgseg from 32560 to 32767 b) msgmnb from 65536 to 65535 c) msgssz from 128 to 256 Then we noticed that all application debug file size increase upto 2GB then it stops. So far we did not... (1 Reply)
Discussion started by: mhbd
1 Replies

9. AIX

loop through the directory for files and sort by date and process the first file

hello i have a requirement where i have a direcotry in which i get files in the format STOCKS.20080114.dat STOCKS.20080115.dat STOCKS.20080117.dat STOCKS.20080118.dat i need to loop through the directory and sort by create date descending order and i need to process the first file. ... (1 Reply)
Discussion started by: dsdev_123
1 Replies

10. Shell Programming and Scripting

Capture output of program to file with limited filesize

I'm working on a script that will perform a backup, save a log of said backup and send the output to me in an email. Everything is working fine so far except that I can't figure out how to specify a maximum file size for the log file. I don't want a runaway log file jamming up the server.... (7 Replies)
Discussion started by: spectre_240sx
7 Replies
Login or Register to Ask a Question