From aa546c4fcbc76437568b894c9af73860ac5b5018 Mon Sep 17 00:00:00 2001 From: Aadit Agrawal Date: Fri, 17 Jan 2025 10:50:15 +0530 Subject: [PATCH] Upload files to "OS/bash/Week3" --- OS/bash/Week3/q7.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 OS/bash/Week3/q7.sh diff --git a/OS/bash/Week3/q7.sh b/OS/bash/Week3/q7.sh new file mode 100644 index 0000000..5109015 --- /dev/null +++ b/OS/bash/Week3/q7.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "Enter the text file" +read file + +line_no=1 +while IFS= read -r line;do +if [ "$((line_no%2))" -eq 1 ]; then +echo "$line" >> temp +fi +((line_no++)) +done<"$file" + +mv temp "$file" + +echo "Even numbered lines deleted" +