Sponsored Content
Top Forums Shell Programming and Scripting Copying the Header & footer Information to the Outfile. Post 302550475 by filter on Friday 26th of August 2011 12:16:41 AM
Old 08-26-2011
Hi yazu,

Really appreciate for your post. Thanks a lot for your answer and thoughts.

Code:
The simplest way is to read the whole file in array, split it to four  parts, process then and write the result in the output file. Because  it's really simple and quick then perhaps you should do it in that way.  There are a lot of things in the world else you can do or improve or  learn.

yes you are correct. I did tried the logic to save the entire file into an array and then tried to divide the parts.

But I was struck to do the following points Inside the script:
1) How to write the footer information into the goodfile inside the perl script.
2) Thought of using a counter to calculate the number of lines and then how do I substitute the number in the footer information.

Really appreciate your thoughts using Unix and I did learn a lot from your post.

Is there any way we can do the same in Perl Script itself.

Thanks a lot for your replies.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

remove header and footer rows

I would like to remove some lines from begining of file (header) and some lines from end of file (footer). The header/footer lines generated by web-browser when the user upload a file to my webserver. Example: -----------------------------7d62af20c052c Content-Disposition: form-data;... (2 Replies)
Discussion started by: seaky
2 Replies

2. Shell Programming and Scripting

rowcnt except Header & Footer

Hi Gurus, My requirement is, I am passing a file1.dat into this(rowcnt.sh) script,but returning a wrong value of -2.(it should be 4).Becoz my file1.dat contains 6records incl: Header & Footer.(6-2=4) wrong output: ------- #sh rowcnt.sh file1.dat -2 actual_cnt except HDR & FTR should be:... (3 Replies)
Discussion started by: vsubbu1000
3 Replies

3. Shell Programming and Scripting

Inserting Header and footer

Hi All, I have several txt files i need to enter specific header and footer (both are separate) to all these files how can i do this? plz help.. Regards, Raghav (4 Replies)
Discussion started by: digitalrg
4 Replies

4. Shell Programming and Scripting

How to add header and footer?

Hi, Guys, I want add header and footer in a file. I can add footer using following command: echo "Footer" >>file. I don't know how to add header. Thanks in advance (4 Replies)
Discussion started by: ken002
4 Replies

5. UNIX for Dummies Questions & Answers

Help with the Header and Footer check

Hi, I need to check whether the incoming file has a header and footer using a UNIX script. The pattern of the header and footer is fixed as follows: Header: Name,Date Footer: Count, Total Name,Date ------------------------- ------------------------- ------------------------- Count,... (5 Replies)
Discussion started by: Sunny_teotia
5 Replies

6. Shell Programming and Scripting

copying file information using awk & grep

Hi, TASK 1: I have been using this code to print the information of files kept at "/castor/cern.ch/user/s/sudha/forPooja" in some text file name FILE.txt. rfdir /castor/cern.ch/user/s/sudha/forPooja | grep data | awk '{print "rfio:///castor/cern.ch/user/s/sudha/forPooja/"$9}' > FILE.txt ... (6 Replies)
Discussion started by: nrjrasaxena
6 Replies

7. Shell Programming and Scripting

Header and Footer...

Hi All, I need to write a script that In my file I have to check header and footer records are available or not. If it is available I have to run the script, otherwise I should not. But current script it is checking only the data inside the script. It is avoiding to check Header and Footer... (1 Reply)
Discussion started by: suresh_target
1 Replies

8. Shell Programming and Scripting

Removing header and footer

I have two files which are getting sent to a UNIX server in order to be bcp'd into a database. The bcp is failing because there's a header and footer row on the file which give the date of the file and the number of rows in it. That's because the file is also being used for another process, so we... (1 Reply)
Discussion started by: Tom Sawyer
1 Replies

9. Shell Programming and Scripting

Add header and footer with record count in footer

This is my file(Target.txt) name|age|locaction abc|23|del xyz|24|mum jkl|25|kol The file should be like this 1|03252012 1|name|age|location 2|abc|23|del 2|xyz|24|mum 2|jkl|25|kol 2|kkk|26|hyd 3|4 Column 1 is row indicator for row 1 and 2, column indicator is 1,for data rows... (1 Reply)
Discussion started by: itsranjan
1 Replies

10. Shell Programming and Scripting

Strip header and footer

Hi I have below requirements on the script below : (1) I receive 2 pipe seperated file called OUT.psv and DIFF.psv with a column header.I concatenate the 2 files and create a final.psv file. I want to add another header as START_FILE to the final.psv file . How to achieve this ? (2) I have... (5 Replies)
Discussion started by: samrat dutta
5 Replies
Internals(3pm)						User Contributed Perl Documentation					    Internals(3pm)

NAME
CallingTk - what is Perl Tk interface doing when you call Tk functions. This information is worse than useless for "perlTk" users, but can of some help for people interested in using modified Tk source with "perlTk". This document is under construction. The information is believed to be pertinent to the version of "portableTk" available when it was created. All the details are subject to change. DESCRIPTION
PreCompiling Before the actual compilation stage a script scans the source and extracts the subcommands of different commands. This information resides in the file "pTk/Methods.def". Compilation During compilation the above file is included in the source of booting routine of dynamic (or static) library. More precisely, the booting code of module "Tk" calls the subroutine Boot_Glue() from the module "tkGlue.c", and this subroutine includes the file (with appropriate macro definitions). Inside "use Tk;" The module bootstraps the C code, then loads the Perl libraries. The heart of the Perl code is contained in the "Tk::Widget" library, all the widgets inherit from this module. Code for toplevels is loaded from "Tk::MainWindow". During bootstrap of the C glue code the "Xevent::?" codes and a handful of "Tk::Widget" and "Tk::Image" routines are defined. (Much more XSUBs are created from "Tk.xs" code.) The widget subcommands are glued to Perl basing on the list included from "pTk/Methods.def". In fact all the subcommands are glued to XSUBs that are related to the same C subroutine XStoWidget(), but have different data parts. During the Perl code bootstrap the method "Tk::Widget::import" is called. This call requires all the code from particular widget packages. Code from the widget packages calls an obscure command like (bless "Text")->WidgetClass; This command (actually Tk::Widget::WidgetClass()) creates three routines: Tk::Widget::Text(), Tk::Widget::isText(), and Tk::Text::isText(). The first one is basically "new" of "Tk::Text", the other two return constants. It also puts the class into depository. Inside "$top = MainWindow->new;" This is quite intuitive. This call goes direct to "Tk::MainWindow::new", that calls XSUB "Tk::MainWindow::CreateMainWindow", that calls C subroutine Tk_CreateMainWindow(). It is a "Tk" subroutine, so here black magic ends (almost). The only remaining black magic is that the "Tk" initialization routine creates a lot of commands, but the subroutine for creation is usurped by portableTk and the commands are created in the package "Tk". They are associated to XSUBs that are related to one of three C subroutines XStoSubCmd(), XStoBind(), or XStoTk(), but have different data parts. The result of the call is blessed into "Tk::MainWindow", as it should. Inside "$top->title('Text demo');" The package "Tk::Toplevel" defines a lot of subroutines on the fly on some list. All the commands from the list are converted to the corresponding subcommands of "wm" method of the widget. Here subcommand is a command with some particular second argument (in this case "title"). Recall that the first argument is $self. Now "Tk::Toplevel" @ISA "Tk::Widget", that in turn @ISA "Tk". So a call to "$top->wm('title','Text demo')" calls "Tk::wm", that is defined during call to Tk_CreateMainWindow(). As it is described above, the XSUB associated to XStoSubCmd() is called. This C routine is defined in "tkGlue.c". It gets the data part of XSUB, creates a "SV" with the name of the command, and calls Call_Tk() with the XSUB data as the first argument, and with the name of XSUB stuffed into the Perl stack in the place there "tk" expects it. (In fact it can also reorder the arguments if it thinks it is what you want). The latter procedure extracts name of "tk" procedure and "clientData" from the first argument and makes a call, using Perl stack as "argv" for the procedure. A lot of black magic is performed afterwards to convert result of the procedure to a Perl array return. Inside "$text = $top->Text(background => $txtBg);" Above we discussed how the command "Tk::Widget::Text" is created. The above command calls it via inheritance. It is translated to Tk::Text::new($top, background => $txtBg); The package "Tk::Text" has no method "new", so the "Tk::Widget::new" is called. In turn it calls "Tk::Text->DoInit($top)", that is "Tk::Widget::DoInit(Tk::Text,$top)", that initializes the bindings if necessary. Then it creates the name for the widget of the form ".text0", and calls "Tk::text('.text0', background => $txtBg)" (note lowercase). The result of the call is blessed into "Tk::Text", and the method "bindtags" for this object is called. Now the only thing to discuss is who defines the methods "text" and "bindtags". The answer is that they are defined in "tkWindow.c", and these commands are created in the package "Tk" in the same sweep that created the command "Tk::wm" discussed above. So the the same C code that corresponds to the processing of corresponding TCL commands is called here as well (this time via "XStoTk" interface). Inside "$text->insert('insert','Hello, world!');" As we discussed above, the subcommands of widget procedures correspond to XSUB "XStoWidget". This XSUB substitutes the first argument $text (that is a hash reference) to an appropriate value from this hash, adds the additional argument after the first one that contains the name of the subcommand extracted from the data part of XSUB, and calls the corresponding Tk C subroutine via "Call_Tk". Ilya Zakharevich <ilya@math.ohio-state.edu> perl v5.14.2 2010-05-29 Internals(3pm)
All times are GMT -4. The time now is 05:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy