diff --git a/ex5.txt b/ex5.txt new file mode 100644 index 0000000..31cb4ab --- /dev/null +++ b/ex5.txt @@ -0,0 +1,13 @@ +#!/bin/bash +read -p "Enter the file path" File_path +if [ -e "$File_path" ]&&[ -w "$File_path" ]; then + echo "File_path exists password are enabled" +if [ -w "$File_path" ]; +then + echo "you have permission to edit "$File_path"" +else + echo "you do not have a permission to edit "$File_path"" +fi +else + echo "$File_path does not exist" +fi \ No newline at end of file diff --git a/ex6.txt b/ex6.txt new file mode 100644 index 0000000..15cefa2 --- /dev/null +++ b/ex6.txt @@ -0,0 +1,6 @@ +#!/bin/bash +ANIMALS=("MAN" "BEAR" "PIG" "DOG" "SHEEP") +for ((i=0; i<=${#ANIMALS[@]}; i++)) +do + echo "${ANIMALS[i]}" +done \ No newline at end of file diff --git a/function_ex1.txt b/function_ex1.txt new file mode 100644 index 0000000..be5faa7 --- /dev/null +++ b/function_ex1.txt @@ -0,0 +1,6 @@ +#!/bin/bash +file_count() { + count=$(ls) + echo "There are $count files in present working directory" +} +file_count \ No newline at end of file diff --git a/wildcards_ex1.txt b/wildcards_ex1.txt new file mode 100644 index 0000000..ba6d777 --- /dev/null +++ b/wildcards_ex1.txt @@ -0,0 +1,9 @@ +#!/bin/bash +TODAT=$(date +%Y-%m-%d) +for file in *.jpg; +do + if [ -f "$file" ]; then + mv "$file" "${TODAY}-${file}" + echo "Renamed $file to ${TOADY}-${file}" + fi +done \ No newline at end of file