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

Give an idea of system variables.

797


In Informatica,for the table I can find coreesponding dependent mappings.Likewise can I find the dependent jobs with all the information by using the table name

2241


CHANGE CAPTURE

1105


How do you remove duplicate values in datastage?

877


how many rows sorted in sort stage by default in server jobs

3765


What are the types of containers in datastage?

948


How we can covert server job to a parallel job?

797


what is the custome stage in datastage? how can we impliment that one? plz tell me

2158


What is the difference between account and directory options ?

891


Define Routines and their types?

859


How do you run datastage job from the command line?

845


How can we perform the 2nd time extraction of client database without accepting the data which is already loaded in first time extraction?

2114


project Steps,hits, Project level HArd things,Solved methods?

1854


What are the repository tables in datastage?

1071


In a batch if a job fails in between and you want to restart the batch from that particular job and not from the scratch then what will you do?

813