The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
file creation whizkidash Shell Programming and Scripting 1 03-25-2008 09:07 AM
FTP and LOg file creation agarwalniru Shell Programming and Scripting 2 03-12-2008 11:10 AM
creation of a file infyanurag Linux 1 01-25-2008 07:26 AM
csv file creation Student37 UNIX for Dummies Questions & Answers 2 02-25-2006 02:38 PM
Year of file creation encrypted UNIX for Dummies Questions & Answers 6 04-23-2005 02:20 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-08-2008
ganapati's Avatar
ganapati ganapati is offline
Registered User
  
 

Join Date: Jul 2006
Location: Mysore
Posts: 125
Post 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 (permalink)  
Old 01-08-2008
Klashxx's Avatar
Klashxx Klashxx is offline Forum Advisor  
HP-UX/Linux/Oracle
  
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 393
Please post output and source files examples.
  #3 (permalink)  
Old 01-08-2008
Lokesha Lokesha is offline
Registered User
  
 

Join Date: May 2006
Posts: 26
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 (permalink)  
Old 01-08-2008
ganapati's Avatar
ganapati ganapati is offline
Registered User
  
 

Join Date: Jul 2006
Location: Mysore
Posts: 125
Yes, file layout should be as mentioned above by Lokesha.

Thanks / Ganapati
  #5 (permalink)  
Old 01-08-2008
penyu penyu is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 11
maybe this solve the problem?
to print content between two string:

awk '/Header3/,/Trailer/' inputfile
  #6 (permalink)  
Old 01-09-2008
ganapati's Avatar
ganapati ganapati is offline
Registered User
  
 

Join Date: Jul 2006
Location: Mysore
Posts: 125
Smile

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 (permalink)  
Old 01-18-2008
bobbygsk bobbygsk is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 90
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0