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
How one source columns or rows to be loaded in to two different tables?
Which commands are used to import and export the datastage jobs?
which r the connectors used in san?
How a routine is called in datastage job?
Describe link sort?
Can you explain engine tier in information server?
How can we perform the 2nd time extraction of client database without accepting the data which is already loaded in first time extraction?
how to add a new records into source?
What are the job parameters?
How many areas for files does datastage have?
What are orabulk and bcp stages?
In work load management there are three options of Low priority, Medium priority and High Priority Jobs which can be used for resource management. why this feature is developed when there is already jobs prescheduled by scheduler or autosys. what will be the use of workload management then?
What is the sortmerge collector?
What are the different plug-ins stages used in your projects?
What are the functionalities of link partitioner?