Sponsored Content
Top Forums Shell Programming and Scripting Add header and footer with record count in footer Post 302612157 by kevintse on Saturday 24th of March 2012 11:45:10 PM
Old 03-25-2012
I assume the first row is the current date.
Code:
awk 'BEGIN{"date +%m%d%Y" | getline first; print "1|" first} {if(NR>1){print "2|"$0}else{print "1|"$0} ++c}END{print "3|"c}' infile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to Chop Header and Footer record from input file

Hi, I need to chope the header and footer record from an input file and make a new output file, please let me know how i can do it in unix.thanks. (4 Replies)
Discussion started by: coolbudy
4 Replies

2. Shell Programming and Scripting

Split large file and add header and footer to each file

I have one large file, after every 200 line i have to split the file and the add header and footer to each small file? It is possible to add different header and footer to each file? (1 Reply)
Discussion started by: ashish4422
1 Replies

3. Shell Programming and Scripting

Split large file and add header and footer to each small files

I have one large file, after every 200 line i have to split the file and the add header and footer to each small file? It is possible to add different header and footer to each file? (7 Replies)
Discussion started by: ashish4422
7 Replies

4. 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

5. 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

6. 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

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. UNIX for Dummies Questions & Answers

File Row Line Count without Header Footer

Hi There! I am saving the file count of all files in a directory to an output file using: wc -l * > FileCount.txt I get: 114 G4SXORD 3 G4SXORH 0 G4SXORP 117 total But this count includes header and footer. I want to subtract 2 from the count and get ... (7 Replies)
Discussion started by: gagan8877
7 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
nl(1)							      General Commands Manual							     nl(1)

Name
       nl - line numbering filter

Syntax
       nl [-h type] [-b type] [-f type] [-v start#] [-i incr] [-p ] [-l num] [-s sep] [-w width] [-n format] [-d delim] file

Description
       The  command reads lines from the named file or from the standard input, if no file is named, and reproduces the lines on the standard out-
       put.  Lines are numbered on the left in accordance with the command options in effect.

       The command views the text it reads in terms of logical pages.  Line numbering is reset at the start of each logical page.  A logical  page
       consists  of  a header, a body, and a footer section.  Empty sections are valid.  Different line numbering options are independently avail-
       able for header, body, and footer.  For example, you can elect not to number header and footer lines while numbering  blank  lines  in  the
       body.

       The start of logical page sections is signaled by input lines containing nothing but the following delimiter characters:

		 Line contents	Start of

		 ::: 	header

		 ::		body

		 :		footer

       Unless otherwise specified, assumes that the text it is reading is in the body of a single logical page.

Options
       Command options may appear in any order and may be intermingled with an optional file name.  Only one file may be named.

       -b type		   Specifies  which  logical page body lines are to be numbered.  The following are recognized types and their meaning: a,
			   number all lines; t, number lines with printable text only; n, no line numbering; pstring, number only lines that  con-
			   tain the regular expression specified in string.

			   The default type for logical page body is t (text lines numbered).

       -h type		   Same as -b type except for header.  Default type for logical page header is n (no lines numbered).

       -f type		   Same as -b type except for footer.  Default for logical page footer is n (no lines numbered).

       -p		   Do not restart numbering at logical page delimiters.

       -v start#	   The initial value used to number logical page lines.  Default is 1.

       -i incr		   The increment value used to number logical page lines.  Default is 1.

       -s sep		   The character used in separating the line number and the corresponding text line.  Default sep is a tab.

       -w width 	   The number of characters used for the line number.  Default width is 6.

       -n format	   The	line  numbering  format.   Recognized values are the following: ln, left justified, leading zeroes suppressed; rn,
			   right justified, leading zeroes suppressed; rz, right justified, leading zeroes kept.  Default format is rn (right jus-
			   tified).

       -l num		   The	number	of  blank lines to be considered as one.  For example, -l2 results in only the second adjacent blank being
			   numbered (if the appropriate -ha, -ba, or -fa option is set).  Default is 1.

       -d xx		   The delimiter characters specifying the start of a logical page section may be changed from the default characters (:)
			   to two user-specified characters.  If only one character is entered, the second character remains the default character
			   (:).  No space should appear between the -d and the delimiter characters.  To enter a  backslash,  you  must  type  two
			   backslashes (//).

Examples
       nl -v10 -i10 -d!+ file1
       This command numbers file1 starting at line number 10 with an increment of ten.	The logical page delimiters are !+.

See Also
       pr(1)

																	     nl(1)
All times are GMT -4. The time now is 01:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy