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
Answers were Sorted based on User's Feedback
Answer / roshini
echo enter filename
read file
for n in `cat $file`
do
i=`expr $n % 2`
if [ $i -eq 0 ]
then
echo $n>>even.txt
else
echo $n>>odd.txt
fi
done
| Is This Answer Correct ? | 19 Yes | 4 No |
Answer / jaya prasad
echo "Enter the file name"
read file
awk '$NF % 2 == 0' $file > file1.txt
awk '$NF % 2 != 0' $file > file2.txt
| Is This Answer Correct ? | 9 Yes | 1 No |
Answer / 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 |
Answer / rahul
Can someon just use only one line script if we already knew the file name
| Is This Answer Correct ? | 0 Yes | 0 No |
how do you write sql queries using shell script for eg:- we have databae table like EMPNO,ENAME,SAL,DEPTNO columns in EMP table how you display EMPNO,SAL FIELDS from emp in SHELL SCRIPT please explain with an example
What is the default ubuntu terminal?
What are environment variables?
what are command line arguments? what is the need of those?
c program which accept one argument as a directory name and prints all the file name along with its inode number and total count of the file in directory
How do I open a jshell in cmd?
What does path stand for?
What is scripting autism?
c program the catches the ctrl-c(SIGINT) Signal for the first time and prints a output rather and exit on pressing Ctrl-C again
Explain about sourcing commands?
What is an sh file?
What is the first line in every perl script called?