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 / 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 |
Post New Answer View All Answers
What is echo in shell?
Can we run shell script in windows?
What's the difference between scripting and coding?
What is the syntax of while loop in shell scripting?
How to get the 3rd element/column from each line from a file?
What shell is bin sh?
Is shell scripting useful?
Print the 10th line without using tail and head command.
What is the meaning of $1 in shell script?
What are the two files of crontab command?
How do you find out What is your shell?
Hello all, This is my assignment on shell scripting, can anyone help me regarding this ? Create a shell script which connects to the database In second shell script include the first script for the DB connection Create a table (PRADEEP_DATA) with 2 columns (name, value) In Third shell script include the first script for the DB connection And insert/delete the values from the Table, by accepting input from the user This functionality should be a menu driven Program: 1) Insert to the database a. Name b. value 2)Delete from the database a.Name b.value Exception handling needs to be taken care.
What are the four fundamental components of every file system on linux?
What is basename in shell script?
Why are shell scripts used?