I want Trailer to be added into the text file.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting I want Trailer to be added into the text file.
Prev   Next
# 1  
Old 04-02-2009
I want Trailer to be added into the text file.

Hi folks,

I want Trailer to be added into the txt file the format is below.

flatfile-> abc.txt

count of the file is 500 records.

I want the trailer in this format: TRAILER|500 (pipe delimeter).

Please suggest the comands ASAP.

Rgds
Ann
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sending mail to multiple recipient added in a text file

I am trying to find a code that can help me mail to a list of recipients which are in a text file. Sample code $cat recipient.txt me@test.com me1@test.com me2@test.com I want a mailx step that can read contents of recipient.txt and mail to all the users. I don't want to use mails... (1 Reply)
Discussion started by: Gurkamal83
1 Replies

2. Programming

Dynamically added text fields passed to PHP script

If I am posting this to the wrong section please move it somewhere it fits. I apologize if this is not the correct section. I have a site where I want to have form that in a "Visitor name" section to be able to add fieldets as needed. I think I have that worked out. So the below code is the... (4 Replies)
Discussion started by: GroveTuckey
4 Replies

3. Shell Programming and Scripting

Verify the header and trailer in file

please see my requirement, I hope I am clear. (9 Replies)
Discussion started by: mirwasim
9 Replies

4. Shell Programming and Scripting

Script to validate file header and trailer

Hi, I need a script that validates a file header/detail/trailer. File layout is: Header - Rec_Type|File_name|File_Date Detail - Rec_Type|field1|field2|field3... Trailder - Rec_Type|File_name|File_Date|Record_count Sample Data: HDR|customer_data.dat|20120709... (7 Replies)
Discussion started by: ash_sh
7 Replies

5. UNIX for Dummies Questions & Answers

Adding header and trailer into a file

Hi, I want to add the below Header to all the files in sequence File1,File2,File3...etc "ABC,<number of chracter in the file>" e,g - If File1 is as below pqrstuvdt abcdefgh then I want to add the above header into it ,So that File1 becomes as below ABC,17 pqrstuvdt abcdefgh ... (9 Replies)
Discussion started by: spari2
9 Replies

6. Shell Programming and Scripting

Need to echo a text where a (.) is added to the end of line during on-going copy or ftp

Hello All, I would like to create a script to echo a text where a (.) dot is added every 2 seconds to the end of this text (with a limit of 10 dots) as long as a file copy or ftp is ongoing and once the copy is finished it adds "done" to the end of this text line. please see the below example: ... (6 Replies)
Discussion started by: Dendany83
6 Replies

7. Shell Programming and Scripting

Removing Header & Trailer from a file

Hi All, I am karthik. I am new to this forum. I have one requirement. I have a file with header and footer. Header may be like HDR0001 or FILE20090110 (Assume it is unknown so far, but i am sure there is a header in the file) likewise file has the trailer too. I just... (7 Replies)
Discussion started by: karthi_gana
7 Replies

8. Shell Programming and Scripting

Merge text files while combining the multiple header/trailer records into one each.

Situation: Our system currently executes a job (COBOL Program) that generates an interface file to be sent to one of our vendors. Because this system processes information for over 100,000 employees/retirees (and growing), we'd like to multi-thread the job into processing-groups in order to... (4 Replies)
Discussion started by: oordonez
4 Replies

9. Shell Programming and Scripting

Get the latest added part of a text file?

Hi, I want to get the latest added part of a text file sent over the network to for analysis. Is there a tool to use to keep track of which part of a text file that has already been analysed so only the "new" lines will be sent and handled? I have checked a few tools but I still donīt know how to... (3 Replies)
Discussion started by: pcrs
3 Replies

10. UNIX for Dummies Questions & Answers

Removing trailer from a flat file!!!

Hi, I get some flat files with trailer which gives the totol records count and i want to remove the trailer from the file. i used the following command it works fine with a single file. cat file_name | grep -v 'Total records:' > file1 mv file file_name But i dont know how to remove the... (12 Replies)
Discussion started by: kumarsaravana_s
12 Replies
Login or Register to Ask a Question
Term::Sk(3pm)						User Contributed Perl Documentation					     Term::Sk(3pm)

NAME
Term::Sk - Perl extension for displaying a progress indicator on a terminal. SYNOPSIS
use Term::Sk; my $ctr = Term::Sk->new('%d Elapsed: %8t %21b %4p %2d (%8c of %11m)', {quiet => 0, freq => 10, base => 0, target => 100, pdisp => '!'}); $ctr->up for (1..100); $ctr->down for (1..100); $ctr->whisper('abc'); my last_line = $ctr->get_line; $ctr->close; print "Number of ticks: ", $ctr->ticks, " "; EXAMPLES
Term::Sk is a class to implement a progress indicator ("Sk" is a short form for "Show Key"). This is used to provide immediate feedback for long running processes. A sample code fragment that uses Term::Sk: use Term::Sk; print qq{This is a test of "Term::Sk" }; my $target = 2_845; my $format = '%2d Elapsed: %8t %21b %4p %2d (%8c of %11m)'; my $ctr = Term::Sk->new($format, {freq => 10, base => 0, target => $target, pdisp => '!'}); for (1..$target) { $ctr->up; do_something(); } $ctr->close; sub do_something { my $test = 0; for my $i (0..10_000) { $test += sin($i) * cos($i); } } Another example that counts upwards: use Term::Sk; my $format = '%21b %4p'; my $ctr = Term::Sk->new($format, {freq => 's', base => 0, target => 70}); for (1..10) { $ctr->up(7); sleep 1; } $ctr->close; At any time, after Term::Sk->new(), you can query the number of ticks (i.e. number of calls to $ctr->up or $ctr->down) using the method 'ticks': use Term::Sk; my $ctr = Term::Sk->new('%6c', {freq => 's', base => 0, target => 70}); for (1..4288) { $ctr->up; } $ctr->close; print "Number of ticks: ", $ctr->ticks, " "; This example uses a simple progress bar in quiet mode (nothing is printed to STDOUT), but instead, the content of what would have been printed can now be extracted using the get_line() method: use Term::Sk; my $format = 'Ctr %4c'; my $ctr = Term::Sk->new($format, {freq => 2, base => 0, target => 10, quiet => 1}); my $line = $ctr->get_line; $line =~ s/10/</g; print "This is what would have been printed upon new(): [$line] "; for my $i (1..10) { $ctr->up; $line = $ctr->get_line; $line =~ s/10/</g; print "This is what would have been printed upon $i. call to up(): [$line] "; } $ctr->close; $line = $ctr->get_line; $line =~ s/10/</g; print "This is what would have been printed upon close(): [$line] "; Here are some examples that show different values for option {num => ...} my $format = 'act %c max %m'; my $ctr1 = Term::Sk->new($format, {base => 1234567, target => 2345678}); # The following numbers are shown: act 1_234_567 max 2_345_678 my $ctr2 = Term::Sk->new($format, {base => 1234567, target => 2345678, num => q{9,999}}); # The following numbers are shown: act 1,234,567 max 2,345,678 my $ctr3 = Term::Sk->new($format, {base => 1234567, target => 2345678, num => q{9'99}}); # The following numbers are shown: act 1'23'45'67 max 2'34'56'78 my $ctr4 = Term::Sk->new($format, {base => 1234567, target => 2345678, num => q{9}}); # The following numbers are shown: act 1234567 max 2345678 my $ctr5 = Term::Sk->new($format, {base => 1234567, target => 2345678, commify => sub{ join '!', split m{}xms, $_[0]; }}); # The following numbers are shown: act 1!2!3!4!5!6!7 max 2!3!4!5!6!7!8 DESCRIPTION
Format strings The first parameter to new() is the format string which contains the following special characters: characters '%d' a revolving dash, format '/-|' characters '%t' time elapsed, format 'hh:mm:ss' characters '%b' progress bar, format '#####_____' characters '%p' Progress in percentage, format '999%' characters '%c' Actual counter value (commified by '_'), format '99_999_999' characters '%m' Target maximum value (commified by '_'), format '99_999_999' characters '%k' Token which updates its value before being displayed. An example use of this would be a loop wherein every step of the loop could be identified by a particular string. For example: my $ctr = Term::Sk->new('Processing %k counter %c', {base => 0, token => 'Albania'}); foreach my $country (@list_of_european_nations) { $ctr->token($country); for (1..500) { $ctr->up; ## do something... } }; $ctr->close; You can also have more than one token on a single line. Here is an example: my $ctr = Term::Sk->new('Processing %k Region %k counter %c', {base => 0, token => ['Albania', 'South']}); foreach my $country (@list_of_european_nations) { $ctr->token([$country, 'North']); for (1..500) { $ctr->up; ## do something... } }; $ctr->close; The "token" method is used to update the token value. If '%k' is used, then the counter must be instantiated with an intial value for the token. characters '%P' The '%' character itself Options The second parameter are the following options: option {freq => 999} This option sets the refresh-frequency on STDOUT to every 999 up() or down() calls. If {freq => 999} is not specified at all, then the refresh-frequency is set by default to every up() or down() call. option {freq => 's'} This is a special case whereby the refresh-frequency on STDOUT is set to every second. option {freq => 'd'} This is a special case whereby the refresh-frequency on STDOUT is set to every 1/10th of a second. option {base => 0} This specifies the base value from which to count. The default is 0 option {target => 10_000} This specifies the maximum value to which to count. The default is 10_000. option {pdisp => '!'} This option (with the exclamation mark) is obsolete and has no effect whatsoever. The progressbar will always be displayed using the hash-symbol "#". option {quiet => 1} This option disables most printing to STDOUT, but the content of the would be printed line is still available using the method get_line(). The whisper-method, however, still shows its output. The default is in fact {quiet => !-t STDOUT} option {num => '9_999'} This option configures the output number format for the counters. option {commify => sub{...}} This option allows one to register a subroutine that formats the counters. option {test => 1} This option is used for testing purposes only, it disables all printing to STDOUT, even the whisper shows no output. But again, the content of the would be printed line is still available using the method get_line(). Processing The new() method immediately displays the initial values on screen. From now on, nothing must be printed to STDOUT and/or STDERR. However, you can write to STDOUT during the operation using the method whisper(). We can either count upwards, $ctr->up, or downwards, $ctr->down. Everytime we do so, the value is either incremented or decremented and the new value is replaced on STDOUT. We should do so regularly during the process. Both methods, $ctr->up(99) and $ctr->down(99) can take an optional argument, in which case the value is incremented/decremented by the specified amount. When our process has finished, we must close the counter ($ctr->close). By doing so, the last displayed value is removed from STDOUT, as if nothing had happened. Now we are allowed to print again to STDOUT and/or STDERR. Post hoc transformation In some cases it makes sense to redirected STDOUT to a flat file. In this case, the backspace characters remain in the flat file. There is a function "rem_backspace()" that removes the backspaces (including the characters that they are supposed to remove) from a redirected file. Here is a simplified example: use Term::Sk qw(rem_backspace); my $flatfile = "Test hijabc101010xyzklmttt1010yzz"; printf "before (len=%3d): '%s' ", length($flatfile), $flatfile; rem_backspace($flatfile); printf "after (len=%3d): '%s' ", length($flatfile), $flatfile; AUTHOR
Klaus Eichner, January 2008 COPYRIGHT AND LICENSE
Copyright (C) 2008-2011 by Klaus Eichner This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.4 2011-07-19 Term::Sk(3pm)