This is UNIX question asked in DataStage Interview.
Say I have n numbers of records in a text file.
I want first 3 records in 1st file, last three records in 3rd file and remaining n-6 records in 2nd file.
(Note: we don't know how many records are there in the File. I am getting one file on daily basis and I want three target files as asked above)

Answer Posted / reddy

First check the filename how many records are there
wc -l finename
it will give count

then first check the filename if it has header and footer

If not use below unix commands

when we use wc -l filename, it will give count, for example we have 1000 records

Ans1: Head -3 filename.txt >Target1.txt
Ans2: Tail -3 filename.txt >Target3.txt
Ans3: sed -n '4,997p' filename >Target2.txt

Please correct me if i am wrong....

Is This Answer Correct ?    13 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you remove duplicate values in datastage?

908


I/p : F1 table have A,B,C,D,E and F2 table having C,E,V i need output 0utput1: ABD output2: V any one suggest me this

831


Can you explain kafka connector?

1075


How you Implemented SCD Type 1 & Type 2 in your project?

3925


What is the method of removing duplicates, without the remove duplicate stage?

814


Can we use target hash file as a lookup ?

3088


DB2 connector> transformer > sequential file Data will be exported into a csv format in a sequential file. This file will be send in a email using a sequence job. Problem here is, how to avoid sending a blank csv file? When I ran the job there are chances that it might return zero records but in the sequence job csv file is going blank. how can I avoid this? thanks

1302


What are the components of datastage?

895


What is the difference between orabulk and bcp stages?

822


What are the components of ascential data stage?

921


What is a ds designer?

873


Describe stream connector?

1082


What are the types of jobs we have in datastage?

903


how to sort two columns in single job in datastage.

2743


How to manage date conversion in Datastage?

876