Upload files to "OS/bash/Week3"
This commit is contained in:
parent
e27e2c7837
commit
a815332403
11
OS/bash/Week3/q3.sh
Normal file
11
OS/bash/Week3/q3.sh
Normal file
@ -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
|
||||
|
||||
|
8
OS/bash/Week3/q4.sh
Normal file
8
OS/bash/Week3/q4.sh
Normal file
@ -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"
|
10
OS/bash/Week3/q4_1000.sh
Normal file
10
OS/bash/Week3/q4_1000.sh
Normal file
@ -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
|
18
OS/bash/Week3/q5.sh
Normal file
18
OS/bash/Week3/q5.sh
Normal file
@ -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"
|
9
OS/bash/Week3/q6.sh
Normal file
9
OS/bash/Week3/q6.sh
Normal file
@ -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"
|
Loading…
x
Reference in New Issue
Block a user