Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How do you schedule or monitoring the job?

1148


Triggers,VIEW,Procedures

1186


Define ds designer?

1223


What is the difference between hashfile and sequential file?

1198


Define Data Stage?

1046


What all are the different way to run a job?

1040


What are the various kinds of the hash file?

1107


explain about completely flow of sequencers technicaly,without using example??explain about lookup,nullhandling?

2416


What is a datastage job?

973


What are the areas of application?

1103


Can you explain tagbatch restructure operator?

1124


Define Job control?

1083


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

2140


Can you explain how could anyone drop the index before loading the data in target in datastage?

1452


How and where you used hash file?

1120