Sponsored Content
Top Forums Shell Programming and Scripting Script to validate file header and trailer Post 302668689 by agama on Monday 9th of July 2012 10:44:45 PM
Old 07-09-2012
A minimal solution:

Code:
awk -F "|" ' /^HDR/ { h++; next; } /^TRL/ { exit( (h > 1) || $NF != NR - 2 ); }' file-name

If the exit code is non-zero there is an error.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copy all the files with time stamp and remove header,trailer from file

All, I am new to unix and i have the following requirement. I have file(s) landing into input directory with timestamp, first i want to copy all these files into seperate directory then i want to rename these files without timestamp and also remove header,trailer from that file.. Could... (35 Replies)
Discussion started by: ksrams
35 Replies

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

3. Shell Programming and Scripting

Creating Header & Trailer for bulk volume data file

Hi all, I have a requirement to create a Header &Trailer for a file which is having 20 millions of records. If I use the following method, i think it will take more time. cat "Header"> file1.txt cat Data_File>>file1.txt cat "Trailer">>file1.txt since second CAT command has to read all... (4 Replies)
Discussion started by: Raamc
4 Replies

4. Shell Programming and Scripting

Adding Header and Trailer records to a appended file

How can we a shell script and pass date parameters .I have 3 files comming from Datastage with |" delimited I need append 3 files as above: File1: P0000|"47416954|"AU|"000|"INS|"0000|"|"20060601|"99991231|"|"|"|"|"01 File 2:... (2 Replies)
Discussion started by: e1994264
2 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

Remove last few characters in a file but keeping Header and trailer intact

Hi All, I am trying write a simple command using AWK and SED to this but without any success. Here is what I am using: head -1 test1.txt>test2.txt|sed '1d;$d' test1.txt|awk '{print substr($0,0,(length($0)-2))}' >>test2.txt|tail -1 test1.txt>>test2.txt Input: Header 1234567 abcdefgh... (2 Replies)
Discussion started by: nvuradi
2 Replies

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

8. Shell Programming and Scripting

Split and add header and trailer from input file

I need to split the file based on pattern from position 34-37 while retaining the header and trailer records in each individual split file Also is it possible to output the TOM and PAT records in the same output file ? I need the output file names same as xyz_pattern_Datetimestamp.txt ... (23 Replies)
Discussion started by: techedipro
23 Replies

9. UNIX for Advanced & Expert Users

Removing Header and Trailer record of a EBCDIC file

I have a EBCDIC multi layout file which has a header record which is 21 bytes, The Detail records are 2427 bytes long and the trailer record is 9 bytes long. Is there a command to remove the header as well as trailer record and read only the detail records while at the same time not altering... (1 Reply)
Discussion started by: abhilashnair
1 Replies

10. Shell Programming and Scripting

Script to validate header in a csv file

Hi All; I am struggling to write a script that validates file header. Header file would be like below with TAB separated TRX # TYPE REF # Source Piece Code Destination Piece Code every time I need to check the txt file if the header was same as above fields if validation success... (6 Replies)
Discussion started by: heye18
6 Replies
oggz-validate(1)					      General Commands Manual						  oggz-validate(1)

NAME
oggz-validate -- Validate the Ogg framing of one or more files SYNOPSIS
oggz-validate [-M num | --max-errors num ] [-p | --prefix ] [-s | --suffix ] [-P | --partial ] filename ... oggz-validate [-h | --help ] [-v | --version ] Description oggz-validate validates the Ogg framing of one or more Ogg files. oggz-validate detects the following errors in Ogg framing: o File contains no Ogg packets o Packets out of order o Packet belongs to unknown serialno o Granulepos decreasing within track o Multiple bos pages o Multiple eos pages o eos marked but no bos o Missing eos packets o eos marked on page with no completed packets o Granulepos on page with no completed packets o Theora video bos page after audio bos page o Terminal header page has non-zero granulepos o Terminal header page contains non-header packet o Terminal header page contains non-header segment oggz-validate exits with status 0 if all files are valid Ogg files, and with status 1 if one or more errors are found. Options oggz-validate accepts the following options: Error reporting options -M num, --max-errors num Exit after the specified number of errors. A value of 0 specifies no maximum. -p, --prefix Treat input as the prefix of a stream; suppress warnings about missing end-of-stream markers -s, --suffix Treat input as the suffix of a stream; suppress warnings about missing beginning-of-stream markers on the first chain -P, --partial Treat input as a the middle portion of a stream. Equivalent to both --prefix and --suffix Miscellaneous options -h, --help Display usage information and exit. -v, --version Output version information and exit. AUTHOR
Conrad Parker April 3, 2005; COPYRIGHT
Copyright (C) 2005 CSIRO Australia SEE ALSO
oggz-sort(1), oggz-dump(1), oggz-info(1) oggz-validate(1)
All times are GMT -4. The time now is 11:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy