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)
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / ram
head -3 filename.txt > t1.txt
tail -3 filename.txt > t2.txt
cat filename.txt|sed '3d,$d'|sed '$d'|sed '$d' > t3.txt
Is This Answer Correct ? | 0 Yes | 0 No |
when we will use connected Lookup & Unconnected Lookup
What is the use of datastage director?
Differentiate between validated and Compiled in the Datastage?
Difference between server jobs & parallel jobs?
How a routine is called in datastage job?
what are the different type of errors in datastage?
If the job aborted in a sequencer, how can we start that from the previews successful job.
My input has a unique column-id with the values 10,20,30.....how can i get first record in one o/p file,last record in another o/p file and rest of the records in 3rd o/p file?
how can u connect the client system directly at any time?
How to move data set from one server to other?what are the steps to follow to do this?
In the source seq file have 2 columns, i.e input: col1,col2 1,1 2,rajesh 3,15000 4,2 5,suresh 6,16000 7,3 8,veeru 9,17000 I want in the output like: eno,ename,sal 1,rajesh,15000 2,suresh,16000 3,veeru,17000 any one answer this scenario
What are the processing stages?