How to Read Multiple files in a Shell Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to Read Multiple files in a Shell Script
# 1  
Old 08-18-2010
How to Read Multiple files in a Shell Script

Hi,

Can any one tell me if i can read two files in a shell script...

My actual requirement is to read the 1st text file and parse it to get the file code and use this file code to retrieve data from database and print the fetched data in the 2nd text file (I have parsed it and printed the fetched data)

Now i want to read the 2nd text file and get the value for further use in the script...

how should i go about it.

Thanks in advance
# 2  
Old 08-18-2010
You mean something like this ?
Code:
while read i; do 
  get $filename from database using $i
  while read j; do 
    do stuff with $j
  done < "$filename" 
done < file1

# 3  
Old 08-18-2010
ya got it thanks for the reply bro...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Shell Script to sed with Multiple Files

I am not sure what I am doing wrong here. The code should work fine. I have been making small changes insuring that each new bit works. Now running my sed through multiple files I am getting incorrect output. Any help and instruction would be greatly appreciated. The problem - Generalize... (10 Replies)
Discussion started by: Lycopene
10 Replies

2. Shell Programming and Scripting

Script to read multiple files...

I have 7 text files of varying sizes for each month of System Maintenance done during the 2013 calendar year (Jan. 134 jobs, Feb. 84 jobs, Apr. 594 jobs, May 158 jobs, July 69 jobs, Aug. 1 job, Oct. 102 jobs) and I have another text file which contains everything from those 7 files. Each of the... (8 Replies)
Discussion started by: CyberOptiq
8 Replies

3. Shell Programming and Scripting

Read files in shell script code and run a C program on those files

HI, I am trying to implement a simple shell script program that does not make use of ls or find commands as they are quite expensive on very large sets of files. So, I am trying to generate the file list myself. What I am trying to do is this: 1. Generate a file name using shell script, for... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

4. Shell Programming and Scripting

Shell script to read multiple options from file, line by line

Hi all I have spent half a day trying to create a shell script which reads a configuration file on a line by line basis. The idea of the file is that each will contain server information, such as IP address and various port numbers. The line could also be blank (The file is user created). Here... (1 Reply)
Discussion started by: haggismn
1 Replies

5. Shell Programming and Scripting

how to read two text files in the same shell script

Folks i have written two scripts that do reading of csv files , i am currently fetching the all part of the line in to variables and braking the line into several variables. I am doing the same thing in an another shell script, i want to integrate both the scripts in to a single one where i can... (2 Replies)
Discussion started by: venu
2 Replies

6. Shell Programming and Scripting

Multiple files read error in Shell

Hi All, there is a script that reads multiple files in a directory starting with CTG_TMPxx where xx is an integer number. i have a problem in readin the last file. For example, if there are 10 files in that directory, 9 files are read and processed. but the 10th file, its saying as cannot read... (1 Reply)
Discussion started by: vkca
1 Replies

7. Shell Programming and Scripting

need shell or Perl script to read multiple input

I need shell 0r Perl script to read multiple input and do something and come out example: echo “ enter the host names separated by space “ read servers foreach @servers { do do something done} Here host names like host1 host2 host3 . . . . . . . so on Please help me... (8 Replies)
Discussion started by: sreedhargouda
8 Replies

8. Shell Programming and Scripting

Need help for a Shell script to rename multiple files

Hi! I need help to create a shell script to search inside a file and then copy a portion of the search result as the new file name. Basically I was hacked over the weekend and the genius wipe out my drive from my server. I was able to recover alot of files, but biggest problem Is now the... (15 Replies)
Discussion started by: kidney514
15 Replies

9. Shell Programming and Scripting

Shell Script Needed to Read a text from a list files

Hi, Below is my issue which I desperately need and I want a shell script which can do this job. I need this script as I m planning to put this for a system health check. Please assist me. 1. There are 10 log files in a particular location. 2. open each log file. Goto to the end of the... (4 Replies)
Discussion started by: kashriram
4 Replies

10. Shell Programming and Scripting

Shell script to read multiple log files

Hi all, I have to generate some report from shell script .We have stacktrace log file which generate hourly basis. So now my q is that how this shell script will read all stacktrace log file for particlular day and parse accordingly desire output. Any help or suggestion as i am newbie with... (1 Reply)
Discussion started by: esungoe
1 Replies
Login or Register to Ask a Question