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
What is bash used for?
How to pass an argument to a script?
What are different types of shell?
What is the first line in every perl script called?
What are the different variables present in linux shell?
Why are there shells on the beach?
Write a script to print the first 10 elements of fibonacci series.
Is shell scripting a programming language?
What is the use of "$?" Sign in shell script?
What is batch file programming?
What are zombie processes?
What is wc in shell script?
How can the contents of a file inside jar be read without extracting in a shell script?
How to redirect both standard output and standard error to the same location?
What is sh in shell script?