diff --git a/OS/bash/Week3/q3.sh b/OS/bash/Week3/q3.sh new file mode 100644 index 0000000..85ae1a2 --- /dev/null +++ b/OS/bash/Week3/q3.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +echo "Changing all files with .txt to .text" +x=`find . -type f -iname "*.txt"` +for i in $x;do +j=`echo "$i" | cut -d '.' -f 2` +echo $j +mv $i ./$j.text +done + + diff --git a/OS/bash/Week3/q4.sh b/OS/bash/Week3/q4.sh new file mode 100644 index 0000000..8c63f81 --- /dev/null +++ b/OS/bash/Week3/q4.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +echo "Enter Basic Salary" +read basic +echo "Enter TA" +read TA +GA=$(echo "$basic + $TA + 0.1*$basic" | bc -l) +echo "$GA" diff --git a/OS/bash/Week3/q4_1000.sh b/OS/bash/Week3/q4_1000.sh new file mode 100644 index 0000000..2b9fa95 --- /dev/null +++ b/OS/bash/Week3/q4_1000.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +echo "Enter Basic Salary" +read basic +echo "Enter TA" +read TA +GA=$(echo "$basic + $TA + 0.1*$basic" | bc -l) +for i in $(seq 1 1000);do +echo "$GA" +done diff --git a/OS/bash/Week3/q5.sh b/OS/bash/Week3/q5.sh new file mode 100644 index 0000000..0841242 --- /dev/null +++ b/OS/bash/Week3/q5.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +echo "Enter the file extension" +read ext + +echo "Enter the destination folder" +read dest + +mkdir -p "$dest" + +files=$(find . -maxdepth 1 -type f -name "*.$ext") +echo "$files" + +for file in $files; do + cp "$file" "$dest" +done + +echo "Successfully copied files to target directory" diff --git a/OS/bash/Week3/q6.sh b/OS/bash/Week3/q6.sh new file mode 100644 index 0000000..c11b494 --- /dev/null +++ b/OS/bash/Week3/q6.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +for file in *;do +if [ -f "$file" ];then +sed -i -E 's/(^|\.)ex:/\1Exammple:/g' "$file" +fi +done + +echo "File modified"