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 a file basename?
How do I read a .sh file?
Why are there shells on the beach?
What is shell chemistry?
How to set an array in linux?
How to get script name inside a script?
Why is used in shell scripting?
Why do we write bin bash in shell scripts?
What is a boot block?
What is a batch file used for?
How do I run a bin bash script?
What is another name for a bash shell script that you might see?
What are the different types of commonly used shells on a typical linux system?
What is the significance of the shebang line in shell scripting?
What is awk in shell scripting?