03-13-2006
Remove header(first line) and trailer(last line) in ANY given file
Hi,
I need some help in removing the header (first line) and the trailer (last line) in a give file...
The data file actually comes in EBCDIC format and I converted it into ASCII..
Now I need to strip off the first line and the last line..
I think we can use sed to do something like this:
sed -n -e '2,964p' InPutFile.dat > OutPutFile.dat
Since I know the file has 965 rows, I could do this...But I would like to automate this script..
Thank you,
Madhu
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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
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
Hi All,
In my file i need to remove header and trailer records which comes in 1st line and last line respectively. After that i need to replace '$\|' with '$#@'.
I am using sed command for this and its taking lot of time. Is there any other command which can be used to improve performance?
... (1 Reply)
Discussion started by: HemaV
1 Replies
4. Shell Programming and Scripting
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
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
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
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
8. Shell Programming and Scripting
please see my requirement, I hope I am clear. (9 Replies)
Discussion started by: mirwasim
9 Replies
9. Shell Programming and Scripting
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
LEARN ABOUT MOJAVE
uuencode
uuencode(5) File Formats Manual uuencode(5)
NAME
uuencode file format
DESCRIPTION
The command generates files in a format that allows them to be successfully transferred by systems which strip the high bit from an 8-bit
byte. decodes uuencoded files.
The uuencode file format consists of three sections: header, body, and trailer. The header is a line is of the form:
begin 644 "filename.ext"
where "644" is a -format permissions byte for the file and "filename.ext" is the name of the encoded file.
The body section is the encoded representation of the source file. Three bytes of input file data are encoded into four bytes of output
data.
The 24 input bits are divided up into four pieces of six bits each. The integer value 32 (the ASCII value for the space character) is added
to each of these pieces to move them outside of the range of control characters. To avoid using the space character in the encoding, pieces
with value zero are encoded using backquote (ASCII value 96) instead of zero. The resulting character is one of the this set (ASCII values
96,33-95):
A line itself contains three segments: a length character (encoded using the "add a space" algorithm described above), the body of the
line, typically (although not required to be) 60 output characters long, representing 45 input bytes, and (of course) a linefeed. The
length character specifies the number of valid input bytes on the line (so, for a line which is 60 encoded bytes, the length value would be
45). Decoding programs should decode no further than the specified length on a single line.
The trailer, which must exist, consists of a single backquote ("`", ASCII 96) character on a line by itself, directly followed by on a line
by itself.
is the canonical filename extension for uuencoded files.
BUGS
uudecode does not read all permutations of the file format described in this man page.
Ancient versions of uuencode used a space character (ASCII 32) in the encoding to represent zero. Many (arguably broken) mailers and trans-
port agents stripped, rewrapped, or otherwise mangled this format, so the space was later changed to the backquote, ASCII 96. Decoders may
attempt to read the older format if they wish, though it's unlikely to be encountered in practice at this point in time.
The uuencode encoding method is highly ASCII-centric. In particular, the character set used doesn't work well on EBCDIC-based systems.
(EBCDIC, generally used by IBM mainframes, is an old alternative character encoding; most computers use ASCII instead).
Many variants of uuencode on various platforms generate different forms of line checksums, using to represent the checksum one or more
encoded characters after the last counted character in a line. Because these formats are different and impossible to distinguish (with
certainty), such characters should be ignored by decoding implementations.
The uuencode encoding format has no provisions for segmented files. Writers of segmenting utilities should be careful to avoid using char-
acter sequences that may naturally occur in the encoding (such as sequences of dashes ("---")) to divide sections.
SEE ALSO
The MIME Base64 encoding (documented in RFC 2045) is a consistent, cross-platform-savvy message encoding which should be used in place of
UUEncode wherever possible.
The Unix-Hater's Handbook (IDG, 1994) identifies the folly of the older zero-encoded-as-space versions of uuencode.
Apple Computer, Inc. May, 2001 uuencode(5)