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
Describe link sort?
Can you explain kafka connector?
How many areas for files does datastage have?
What is developer responsibilities in UAT (user acceptance testing and Post implementation phase?
There are two file are there .1st file contains 5 records and 2nd file contain 10 records in target they want 50 records.how can achieve this
what is 'reconsideration error' and how can i respond to this error and how to debug this
Can you filter data in hashed file?
What is the difference between orabulk and bcp stages?
If we take 2 tables(like emp and dept),we use join stage and how to improve the performance?
sed,awk,head
What are the types of containers?
What are the different kinds of views available in a datastage director?
How many types of sorting methods are available in datastage?
What is the difference between datastage and informatica?
What are the components of datastage?