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

I have 2 files and I want to print the records which are common to both.

703


How can I set the default rwx permission to all users on every file which is created in the current shell?

912


Given a file find the count of lines containing the word "abc".

963


How to print all the arguments provided to the script?

557


What language is shell scripting?

581






Is it possible to substitute "ls" command in the place of "echo" command?

619


How important is shell scripting?

549


What language is used in terminal?

560


Is shell scripting useful?

596


Why should we use shell scripts?

594


What language is bash written in?

567


What are the four fundamental components of every file system on linux?

1168


How many fields are present in a crontab file and what does each field specify?

590


Write down the syntax of "for " loop

612


what is info area how many types?

2297