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...

how to separate the even and odd number generated from one
file to two separate file i.e. even numbers in file1.txt and
odd numbers in file2.txt

Answer Posted / ganeswar bojanapu

#!/bin/bash
echo "Enter a file name"
read file
sed -n '1~2'p $file > oddlines.txt; (or) '1~2p'
sed -n '2~2'p $file > evenlines.txt (or) '2~2p'

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is bash used for?

963


How to pass an argument to a script?

1092


What are different types of shell?

877


What is the first line in every perl script called?

976


What are the different variables present in linux shell?

1042


Why are there shells on the beach?

1052


Write a script to print the first 10 elements of fibonacci series.

2279


Is shell scripting a programming language?

1000


What is the use of "$?" Sign in shell script?

1093


What is batch file programming?

1103


What are zombie processes?

970


What is wc in shell script?

934


How can the contents of a file inside jar be read without extracting in a shell script?

1080


How to redirect both standard output and standard error to the same location?

1109


What is sh in shell script?

959