Creation of output file from list of file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Creation of output file from list of file
# 1  
Old 01-08-2008
Java Creation of output file from list of file

Hi Guru's,

Eventhough I know basic shell scripting, Iam not an expert.
Can any one help me to get a logic/answer for the below requirement:

I've to create an output file "outputfile.txt" from many datafiles (ex: abc.dat, xyz.dat).
Header record layout for "outputfile.txt" should be $variable1 (from position 1-1), $variable2 (from position 16-20) and filled with space (from 021-121).

I've a list file "listfile.lst" which has the datafile names.
I've to read these file names one by one.
From each datafile I've to extract only detail records and have to appended to "outputfile.txt"

Can we do this thorough shell scripting or do we need to use awk?

Amy help would be much appreciated.

Mysore Ganapati
# 2  
Old 01-08-2008
Please post output and source files examples.
# 3  
Old 01-08-2008
Output file should be in the below format

Header
Detailed record 1
.
.
Detailed record n
Trailer


List file is in the below format:

input_file1
input_file2
.
.
input_filen


And input files are in the below format:
Header1
Header2
Header3
Detailed_record1
.
.
Detailed_recordn
Trailer


Fpr any more details pls ask.
# 4  
Old 01-08-2008
Yes, file layout should be as mentioned above by Lokesha.

Thanks / Ganapati
# 5  
Old 01-08-2008
maybe this solve the problem?
to print content between two string:

awk '/Header3/,/Trailer/' inputfile
# 6  
Old 01-09-2008
Bug

Sorry Penyu,

Thanks for your try... But you've not got my question. My requirement is as follows:
  1. I've a list file, which has some datafile names.
  2. My programme has to read this list file (list_file.lst) line by line to get the datafile name.
  3. Each datafile (inputfile) will have 3 header, data records and 1 trailer.
  4. My program has to extract only data records from all the datafiles and has to append to only one output data file (outputfile.dat).

Hope this is clear.
With Regards / Ganapati
# 7  
Old 01-18-2008
I'm also not an expert either but hope this will help you.

getRecords.ksh
============
for i in `cat list_file.lst`
do
grep -iv header $i | grep -iv trailer >> recordsFile
done

I tried this on HPUX using Kshell and it worked.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to print the specific part of the file name with file creation date?

Hello Folks, I have an requirement, where i need to get total count of the file based on creation date with there filename selected pattern. Filename: MobileProtocol.20171228T154200.157115.udr I want to get the count of files created on each day based on a pattern find. find . -type... (7 Replies)
Discussion started by: sadique.manzar
7 Replies

2. UNIX for Dummies Questions & Answers

Output a list of five books with their filename titles into one file

Dear unix forum, could I output a list of five books with their file name titles into one file? In order o output all the contents of all the files with their file names there was: find . -type f | while read x; echo -e "\n$x";cat "$x";done > бетховен.txt In spite of them being successively... (5 Replies)
Discussion started by: Xcislav
5 Replies

3. Shell Programming and Scripting

List creation - Grep a line in a file with a script name

Hi, I have a list file which has script names in them. Some scripts take lists as parameters which inturn have script names. This is basically for sequencing the job run. Eg: List1: test1.ksh test2.ksh test2.lst test3.ksh test3.lst test4.ksh test2.lst: test21.ksh test23.ksh... (7 Replies)
Discussion started by: member2014
7 Replies

4. Homework & Coursework Questions

Loop to Convert a list from an input file and output it to another file

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: A) Write a script, which will take input from a file and convert the number from Centigrade to Fahrenheit... (5 Replies)
Discussion started by: AliTheSnake
5 Replies

5. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

6. Shell Programming and Scripting

Dynamic case creation based on output list from a command

I am attempting to create a script that would allow me to list all the instances associated with a DB2 and then prompt the user to choose which one to issue the db2profile command against. I use the db2 command db2ilist to get a list of the instances for a particular server, but the number of... (7 Replies)
Discussion started by: slatoms
7 Replies

7. Red Hat

Dynamic case creation based on output list from a command

I am attempting to create a script that would allow me to list all the instances associated with a DB2 and then prompt the user to choose which one to issue the db2profile command against. I use the db2 command db2ilist to get a list of the instances for a particular server, but the number of... (1 Reply)
Discussion started by: slatoms
1 Replies

8. Shell Programming and Scripting

Output file list to array?

Hey, guys, scripting newb here. I'm trying to get a list of all .dmg files in a folder and save the output into an array. My first attempt was ARRAY= ( `ls $REIMAGEPATH | grep \.dmg$` ) However, I understand why that doesn't work now (at least I think I do). But I don't know what the... (5 Replies)
Discussion started by: nextyoyoma
5 Replies

9. Shell Programming and Scripting

Help with creating a text file in perl with file creation date.

Hi, I am quite new to Perl scripting and i need to create a .TXT file using perl, with fields (A,B,C,D,E), and this text file should be named with current file creation date "XYZ_CCYYMMDD.TXT" (i.e.XYZ_2011042514:33 PM). Can anyone who has done this, please share their expertise on this... (5 Replies)
Discussion started by: msrahman
5 Replies

10. Solaris

gzip a file and append creation date stamp to file

I want to gzip a file and append the creation date to the end of the file. How can I accomplish this task. Basically they are log files which need a creation date stamp appended to make sure they do not overwrite other log files. -jack (3 Replies)
Discussion started by: jacktravine
3 Replies
Login or Register to Ask a Question