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 |
what is difference between migration project and integration project? can anyone explain with the example Thanks in advance
In one project how many shared containers are created?
what is meant by port ? what is the use of port ? what are the different type of ports and its usage
What is the difference between SQl Loader and OCI in datastage?
What is the purpose of pivot stage and types of containers in datastage
if i have two tables table1 table2 1a 1a,b,c,d 1b 2a,b,c,d,e 1c 1d 2a 2b 2c 2d 2e how can i get data as same as in tables?chandu how can i implement scd typ1 and type2 in both server and in parallel?chandu field1 field2 field3 suresh , 10,324 , 355 , 1234 ram , 23,456 , 450 , 456 balu ,40,346,23 , 275, 5678 how to remove the ,inthe fields?
How and where you used hash file?
What is the default padding character?
data stores in which location while using data set stage as the target?
Hi Gus, Can u pls tell me How can u Call the Shell Scripting/Unix Commands in Job Sequence?
I have oracle enterpaise stage, oracle bulkloader stage, ODBC stage and I want to load data in to target, which of the above stages do I need to use and why?
how do u convert date in 20-12-07 to dec-20-2007 or 20-dec- 2007 or 20-dec-07 in parallel