Upload files to "OS/bash/Week3"

This commit is contained in:
Aadit Agrawal 2025-01-17 10:49:39 +05:30
parent 49b7d5d30c
commit e27e2c7837
5 changed files with 76 additions and 0 deletions

20
OS/bash/Week3/addq3.sh Normal file
View file

@ -0,0 +1,20 @@
#!/bin/bash
echo "Enter the text file"
read file
even_file="evenfile"
odd_file="oddfile"
line_no=1
while IFS= read -r line;do
if [ "$((line_no%2))" -eq 0 ]; then
echo "$line" >> "$even_file"
else
echo "$line" >> "$odd_file"
fi
((line_no++))
done<"$file"
echo "Even and odd numbered lines transferres"