|
Home > Archive > Unix questions > March 2004 > first 200 charactes of an EBCDIC file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
first 200 charactes of an EBCDIC file
|
|
|
| hi,
i have a ebcdic file that contains variable length records, is there any unix command that i can use to take the first 200 characters of every
record from the file and output them to another file? i'm thinking i can use dd to do this but am not sure.
thanks in advance for your help.
-maurice
samuels@seas.upenn.edu
| |
| Ken Andrews 2004-03-10, 2:34 pm |
| <samuels@red.seas.upenn.edu> wrote in message
news:c2nffv$4qns$1@netnews.upenn.edu...
> hi,
> i have a ebcdic file that contains variable length records, is there any
unix command that i can use to take the first 200 characters of every
> record from the file and output them to another file? i'm thinking i can
use dd to do this but am not sure.
I don't have an EBCDIC file to test with, but at a WAG you might be able to
use "cut -c 1-200".
With "dd" you might go "cat source | dd conv=ascii | cut -c 1-200 > target"
| |
|
| thanks.
i tried this but it only gets the first 200 characters of the file, not of every record within the file.
any other suggestions?
-maurice
Ken Andrews (gobble@degook.com) wrote:
: <samuels@red.seas.upenn.edu> wrote in message
: news:c2nffv$4qns$1@netnews.upenn.edu...
: > hi,
: > i have a ebcdic file that contains variable length records, is there any
: unix command that i can use to take the first 200 characters of every
: > record from the file and output them to another file? i'm thinking i can
: use dd to do this but am not sure.
: I don't have an EBCDIC file to test with, but at a WAG you might be able to
: use "cut -c 1-200".
: With "dd" you might go "cat source | dd conv=ascii | cut -c 1-200 > target"
| |
| Stephane CHAZELAS 2004-03-10, 4:35 pm |
| 2004-03-10, 20:00(+00), samuels@red.seas.upenn.edu ():
> thanks.
> i tried this but it only gets the first 200 characters of the file, not of every record within the file.
> any other suggestions?
How are the records separated?
With 0x25 chars?
--
Stéphane ["Stephane.Chazelas" at "free.fr"]
| |
| Ken Andrews 2004-03-10, 4:35 pm |
| <samuels@red.seas.upenn.edu> wrote
> Ken Andrews (gobble@degook.com) wrote:
> : <samuels@red.seas.upenn.edu> wrote in message
> : > hi,
> : > i have a ebcdic file that contains variable length records, is there
any
> : unix command that i can use to take the first 200 characters of every
> : > record from the file and output them to another file? i'm thinking i
can
> : use dd to do this but am not sure.
>
> : I don't have an EBCDIC file to test with, but at a WAG you might be able
to
> : use "cut -c 1-200".
>
> : With "dd" you might go "cat source | dd conv=ascii | cut -c 1-200 >
target"
>
> thanks.
> i tried this but it only gets the first 200 characters of the file, not of
every record within the file.
> any other suggestions?
What type of file is it? Possibly "cut" is unable to spot whatever your
record terminator is; it's likely expecting LF.
As a test, I took a script file, converted it to EBCDIC, then ran the result
file through the above command. I got back exactly what I expected, a set
of lines chopped off at char 40. Input file size 16481, output file size
11079.
| |
|
| i'm not sure. the file comes from an ibm mainframe (it is then ftp'ed
to a unix machine running AIX5.1)
and all i know about it is that it's an ebcdic
variable file (variable length records).
how can i determine what the record separator is?
-maurice
Stephane CHAZELAS (this.address@is.invalid) wrote:
: 2004-03-10, 20:00(+00), samuels@red.seas.upenn.edu ():
: > thanks.
: > i tried this but it only gets the first 200 characters of the file, not of every record within the file.
: > any other suggestions?
: How are the records separated?
: With 0x25 chars?
: --
: Stéphane ["Stephane.Chazelas" at "free.fr"]
| |
|
| thanks.
but this is an ebcdic variable file, the record sizes are not fixed.
-maurice
Ken Andrews (gobble@degook.com) wrote:
: <samuels@red.seas.upenn.edu> wrote
: > Ken Andrews (gobble@degook.com) wrote:
: > : <samuels@red.seas.upenn.edu> wrote in message
: > : > hi,
: > : > i have a ebcdic file that contains variable length records, is there
: any
: > : unix command that i can use to take the first 200 characters of every
: > : > record from the file and output them to another file? i'm thinking i
: can
: > : use dd to do this but am not sure.
: >
: > : I don't have an EBCDIC file to test with, but at a WAG you might be able
: to
: > : use "cut -c 1-200".
: >
: > : With "dd" you might go "cat source | dd conv=ascii | cut -c 1-200 >
: target"
: >
: > thanks.
: > i tried this but it only gets the first 200 characters of the file, not of
: every record within the file.
: > any other suggestions?
: What type of file is it? Possibly "cut" is unable to spot whatever your
: record terminator is; it's likely expecting LF.
: As a test, I took a script file, converted it to EBCDIC, then ran the result
: file through the above command. I got back exactly what I expected, a set
: of lines chopped off at char 40. Input file size 16481, output file size
: 11079.
| |
| Nick Landsberg 2004-03-10, 7:36 pm |
| samuels@red.seas.upenn.edu wrote:
> thanks.
> i tried this but it only gets the first 200 characters of the file, not=
of every record within the file.
> any other suggestions?
> -maurice
>=20
> Ken Andrews (gobble@degook.com) wrote:
> : <samuels@red.seas.upenn.edu> wrote in message
> : news:c2nffv$4qns$1@netnews.upenn.edu...
> : > hi,
> : > i have a ebcdic file that contains variable length records, is ther=
e any
> : unix command that i can use to take the first 200 characters of every=
> : > record from the file and output them to another file? i'm thinking =
i can
> : use dd to do this but am not sure.
>=20
> : I don't have an EBCDIC file to test with, but at a WAG you might be a=
ble to
> : use "cut -c 1-200".
>=20
> : With "dd" you might go "cat source | dd conv=3Dascii | cut -c 1-200 >=
target"
>=20
>=20
It's been a LONG time since I've had to convert EDCBIC so some
of this may be off base.
The "cbs" parameter may be what you need to give to dd.
dd conv=3Dascii cbs=3D200 if=3Dsource of=3Dtarget
No guarantees, but some old unused brain-cells clicked
on that one.
--=20
=D1
"It is impossible to make anything foolproof because fools are so=20
ingenious" - A. Bloch
| |
| Charlie Gibbs 2004-03-10, 11:34 pm |
| In article <c2o0or$blil$1@netnews.upenn.edu> samuels@red.seas.upenn.edu
(samuels) writes:
>i'm not sure. the file comes from an ibm mainframe (it is then ftp'ed
>to a unix machine running AIX5.1)
>and all i know about it is that it's an ebcdic
>variable file (variable length records).
>how can i determine what the record separator is?
There might not be one. In many such files the records are preceded
by a four-byte header. The first two bytes are the record length
(binary, big-endian), and the next two bytes are unused (usually
zero).
--
/~\ cgibbs@kltpzyxm.invalid (Charlie Gibbs)
\ / I'm really at ac.dekanfrus if you read it the right way.
X Top-posted messages will probably be ignored. See RFC1855.
/ \ HTML will DEFINITELY be ignored. Join the ASCII ribbon campaign!
| |
|
| okay, thanks for everyone's input.
-maurice
samuels@seas.upenn.edu
Charlie Gibbs (cgibbs@kltpzyxm.invalid) wrote:
: In article <c2o0or$blil$1@netnews.upenn.edu> samuels@red.seas.upenn.edu
: (samuels) writes:
: >i'm not sure. the file comes from an ibm mainframe (it is then ftp'ed
: >to a unix machine running AIX5.1)
: >and all i know about it is that it's an ebcdic
: >variable file (variable length records).
: >how can i determine what the record separator is?
: There might not be one. In many such files the records are preceded
: by a four-byte header. The first two bytes are the record length
: (binary, big-endian), and the next two bytes are unused (usually
: zero).
: --
: /~\ cgibbs@kltpzyxm.invalid (Charlie Gibbs)
: \ / I'm really at ac.dekanfrus if you read it the right way.
: X Top-posted messages will probably be ignored. See RFC1855.
: / \ HTML will DEFINITELY be ignored. Join the ASCII ribbon campaign!
|
|
|
|
|