I've a file consisting of records with different format.
The first record is of one format.
The following couple of records belong to one format
The last record is of another format
I would like to ouput these three different types of records in 3 different files.
Can I achieve this using sequential file stage?? If yes, then how??
What stage to use if not possible with sequential file stage??
Thanks in advance.
Sequential Stage
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 3593
- Joined: Thu Jan 23, 2003 5:25 pm
- Location: Australia, Melbourne
- Contact:
If your file always has the same mixed format you can split it up using simple Unix commands.
This command will give you the first line:
head -1 filename > newfilename
This one gives you the last line:
tail -1 filename > newfilename
This one gives you the 2nd and 3rd lines:
head-3 filename | tail -2 > newfilename
You can run these three commands from a DataStage routine or from a DSExecute stage in a sequence job.
This command will give you the first line:
head -1 filename > newfilename
This one gives you the last line:
tail -1 filename > newfilename
This one gives you the 2nd and 3rd lines:
head-3 filename | tail -2 > newfilename
You can run these three commands from a DataStage routine or from a DSExecute stage in a sequence job.
Certus Solutions
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
Sequential Stage
Also,
sed '1d;$d' filename >> outfilename
will put all the records in filename except the first and last into outfilename.
-BP
sed '1d;$d' filename >> outfilename
will put all the records in filename except the first and last into outfilename.
-BP