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 a file basename?

1094


How do I read a .sh file?

1174


Why are there shells on the beach?

1190


What is shell chemistry?

1026


How to set an array in linux?

1311


How to get script name inside a script?

1062


Why is used in shell scripting?

1046


Why do we write bin bash in shell scripts?

1057


What is a boot block?

1084


What is a batch file used for?

1124


How do I run a bin bash script?

1080


What is another name for a bash shell script that you might see?

1508


What are the different types of commonly used shells on a typical linux system?

1166


What is the significance of the shebang line in shell scripting?

1194


What is awk in shell scripting?

1072