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

Difference between server jobs & parallel jobs?

1015


Define Data Stage?

1040


On which interface you will be working as a developer?

986


What are the different options associated with dsjob command?

1370


What is oci?

1259


Demonstrate experience in maintaining quality process standards?

2456


Distinguish between informatica & datastage. Which one would you choose and why?

952


Differentiate between Symmetric Multiprocessing and Massive Parallel Processing?

1137


how to use self join using datastage ? can u tell me using stage how can we implemnet the self join

5044


Whats difference betweeen operational data stage (ods) and data warehouse?

1069


How do you import and export data into datastage?

1166


How will you load you daily/monthly jobs datas in to Fact and Dimension table using datastage.

3415


What are datastage sequences?

1056


What are system variables and sequencers in datastage

1068


In a batch if a job fails in between and you want to restart the batch from that particular job and not from the scratch then what will you do?

992