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 the use of "$?" Sign in shell script?
Can shell script run on windows?
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.
What language is shell scripting?
What is a shell script? Can you name some of its advantages?
What is shell and terminal?
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?
How do we create command aliases in a shell?
What does sh mean?
Determine the output of the following command: [ -z “” ] && echo 0 || echo 1
Why is shell scripting important?
How do I edit a .sh file?
How to get the last line from a file using just the terminal?
Explain about return code?
What does it mean to debug a script?