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 the use of "$?" Sign in shell script?

1127


Can shell script run on windows?

1011


I want to create a directory such that anyone in the group can create a file and access any person's file in it but none should be able to delete a file other than the one created by himself.

991


What language is shell scripting?

988


What is a shell script? Can you name some of its advantages?

1004


What is shell and terminal?

948


How can any user find out all information about a specific user like his default shell, real-life name, default directory, when and how long he has been using the system?

1072


How do we create command aliases in a shell?

960


What does sh mean?

1020


Determine the output of the following command: [ -z “” ] && echo 0 || echo 1

969


Why is shell scripting important?

999


How do I edit a .sh file?

1095


How to get the last line from a file using just the terminal?

1185


Explain about return code?

1036


What does it mean to debug a script?

1011