Exer 3
Exer 3
3 Operating Sytems
1. simple.sh
#!/bin/sh
# this is a comment
echo "The number of arguments is $#"
echo "The arguments are $*"
echo "The first is $1"
echo "My process number is $$"
echo "Enter a number from the keyboard: "
read number
echo "The number you entered was $number"
2. guessing_game.sh
#!/bin/sh
while true
do
echo “Enter guess: ”
read guess
if [ ! $guess =~ ^[0-9]* ] || [ $guess -lt 1 ] || [ $guess -gt 100 ]
then
echo “Please enter valid number from 1 - 100”
continue
fi
3. text_conversion.sh
#!/bin/bash
find . -type f -name "*.txt" | while read file; do
filename=$(basename "$file" .txt)
new_filename="$filename.text"
mv "$file" "$new_filename"
done