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 ? | 12 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 |
Source Like department_no, employee_name ---------------------------- 20, R 10, A 10, D 20, P 10, B 10, C 20, Q 20, S and Output should be like this department_no, employee_list -------------------------------- 10, A 10, A,B 10, A,B,C 10, A,B,C,D 20, A,B,C,D,P 20, A,B,C,D,P,Q 20, A,B,C,D,P,Q,R 20, A,B,C,D,P,Q,R,S
How you Implemented SCD Type 1 & Type 2 in your project?
What are the processing stages?
Triggers,VIEW,Procedures
source contains 2 columns comes to target 4 columns how
i have data like sam ram sam raj ram I want two targets trgt1 ram sam trgt2 raj how can i do this in datastage?
Name the different sorting methods in datastage.
CAN WE DECLARE DATASET SET WITH OTHER THAN .DS EXTENTION OR NOT IF YES WHAT IS THE DIFFERENCE U FIND?IF NOT WHY?
Can we use sequential file as source to hash file? Have you do it ?if what error it will give?
how can i get 2nd highest salary in datastage?can u send me ,thanQ 2)if i had source has 2 records 1st record ie 1st column contains 1,2,3 and 2nd coulmn contains 10,10,10 i have to get target as 2nd columns as 20,30,40 how can i?
what is the diff between sequential file and fileset stages?
can we use sequential file as a lookup