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



This is UNIX question asked in DataStage Interview. Say I have n numbers of records in a text file...

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

This is UNIX question asked in DataStage Interview. Say I have n numbers of records in a text file...

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

Post New Answer

More Data Stage Interview Questions

How to LOG 'unmatched Master' records and 'Reject Updates' in log files using MERGE stage?

1 Answers   TCS,


Suppose take my name "Reddyvaraprasad" From source it is coming Reddy vara prasad Need to get As Reddyvara prasad/

4 Answers   TCS,


i have source like deptno,sal 1,2000 2,3000 3,4000 1,2300 4,5000 5,1100 i want target like target1 deptno,sal 1,2000 3,4000 4,5000 target2 2,3000 1,2300 5,1100 with out using transformerstage

6 Answers  


What is a quality stage?

1 Answers  


How do you remove duplicate values in datastage?

0 Answers  






hi, how would i run job1 then job 3 , then job2 in a sequence of job1 ,job2,job3. Thanks sunitha

6 Answers   CTS,


how to read 100 records at a time in source a) hw is it fr metadata Same and b) if metadata is nt same?

0 Answers   HCL,


guys pls tell me where we use sequence jobs exactly in realtime proj explain pls with example.

2 Answers   TCS,


how can we do null handling in sequential files

2 Answers   Reliance,


what is the difference between 7.1,7.5.2,8.1 versions in datastage?

3 Answers   IBM,


Name the third party tools that can be used in datastage?

0 Answers  


Hi all, can u explain header and trailer records in file? If a file has header and trailer /master-detail records how will you read it in datastage?

3 Answers  


Categories