parallel while loop based on the file records


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting parallel while loop based on the file records
# 1  
Old 04-26-2011
parallel while loop based on the file records

Hi,


I need to execute parallel with while loop.

Input File(source_file.csv) contains filenames the below

Code:
source_file.csv file contains

Customer1.txt
Product1.txt
Sales.txt
Emp.txt
Dept.txt

Based on the number of rows that file I want to run the script ‘n' times.
Code:
while source_file.csv|read line
do
       cat $line  # I am applying some logic 
done

the script should run in parallel. I am having some problem with the while loop.
Any help greatly appreciated.

Thanks -suri
# 2  
Old 04-26-2011
"run in parallel" means? For each line in the csv file we can trigger the script.

Whats wrong with your while loop? Try this...

Code:
#!/bin/ksh

while read line
do
  echo $line
  # execute your script here
done < source_file.csv

regards,
Ahamed
# 3  
Old 04-26-2011
Hi

Code:
source_file.csv  contains the 

1,Customer1.txt
2,Product1.txt
3,Sales.txt
4,Emp.txt
5,Dept.txt

Thanks for the quick responce. The script running sequentially but i want to run the script in parallel.

Code:
cat source_file.csv | awk -F"," '{print $2}' |grep -v ^$|
while read line
do
echo $line
#some other logic present here
done

thanks -suri
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace variable value in first file based on records in second

Hello , I have below files a) File A <?xml version="1.0" encoding="UTF-8" standalone="no"?> <root xmlns="http://aaa/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema" version="2.0"> <project name="source"> <mapping name="m_Source"> <parameter... (3 Replies)
Discussion started by: Pratik4891
3 Replies

2. Shell Programming and Scripting

Filter records based on 2nd file

Hello, I want to filter records of a file if they fall in range associated with a second file. First the chr number (2nd col of 1st file and 1st col of 2nd file) needs to be matched. Then if the 3rd col of the first file falls within any of the ranges specified by the 2nd and 3rd cols , then... (4 Replies)
Discussion started by: ritakadm
4 Replies

3. Shell Programming and Scripting

Split file based on records

I have to split a file based on number of lines and the below command works fine: split -l 2 Inputfile -d OutputfileMy input file contains header, detail and trailor info as below: H D D D D TMy split files for the above command contains: First File: H DSecond File: ... (11 Replies)
Discussion started by: Ajay Venkatesan
11 Replies

4. UNIX for Dummies Questions & Answers

Delete records from a big file based on some condition

Hi, To load a big file in a table,I have a make sure that all rows in the file has same number of the columns . So in my file if I am getting any rows which have columns not equal to 6 , I need to delete it . Delimiter is space and columns are optionally enclosed by "". This can be ... (1 Reply)
Discussion started by: hemantraijain
1 Replies

5. UNIX for Dummies Questions & Answers

Filtering records from 1 file based on some manipulation doen on second file

Hi, I am looking for an awk script which should help me to meet the following requirement: File1 has records in following format INF: FAILEd RECORD AB1234 INF: FAILEd RECORD PQ1145 INF: FAILEd RECORD AB3215 INF: FAILEd RECORD AB6114 ............................ (2 Replies)
Discussion started by: mintu41
2 Replies

6. Shell Programming and Scripting

Parallel delete based flag from text file

Hi, I need a unix shell script for this requirement and is URGENT My input text file contains A-1 B-1 C-1 D-2 E-2 F-3 G-3 H-3 I-3 J-4 K-4 L-5 My expected result should be: if flag is 1, it has to delete A, B, C if flag is 2, it has to delete D,E if flag is 3, it has to delete... (1 Reply)
Discussion started by: moses_a
1 Replies

7. Shell Programming and Scripting

Filering records based on date listed in the file

Hi, I have to filter out the records which are more than 6 month old and save the records to a new file which are less than 6 months old. The file format is text1:date(mm/dd/yyyy):text2. For example: abcd:12/01/2009:sdfsdf qwwqwra:11/03/2008:efrdas How can I achieve it? (5 Replies)
Discussion started by: abb
5 Replies

8. Shell Programming and Scripting

Based on num of records in file1 need to check records in file2 to set some condns

Hi All, I have two files say file1 and file2. I want to check the number of records in file1 and if its atleast 2 (i.e., 2 or greater than 2 ) then I have to check records in file2 .If records in file2 is atleast 1 (i.e. if its not empty ) i have to set some conditions . Could you pls... (3 Replies)
Discussion started by: mavesum
3 Replies

9. UNIX for Dummies Questions & Answers

Filtering records of a file based on a value of a column

Hi all, I would like to extract records of a file based on a condition. The file contains 47 fields, and I would like to extract only those records that match a certain value in one of the columns, e.g. COL1 COL2 COL3 ............... COL47 1 XX 45 ... (4 Replies)
Discussion started by: risk_sly
4 Replies
Login or Register to Ask a Question