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 first line of a shell script called?

571


What is in a script?

562


How to check if a directory exists?

553


Explain about the exit command?

566


What is the fastest scripting language?

547






Is shell a scripting language?

570


What is the first line in every perl script called?

551


Calculate a real number calculation directly from the terminal and not any shell script.

654


Explain about gui scripting?

622


What are the different commands available to check the disk usage?

489


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

529


What's the difference between scripting and coding?

595


What are the different types of variables used in shell script?

549


Why should we use shell scripts?

587


How important is shell scripting?

543