Assignment 6 U22CS040
Assignment 6 U22CS040
#CODE
if [ $# -eq 0 ]; then
echo "Usage: $0 word file1"
exit 1
fi
word="$1"
shift
#FILE
#OUTPUT
#FILE
#CODE
if [ $# -eq 0 ]; then
echo "Usage: $0 directory_path"
exit 1
fi
directory="$1"
if [ -d "$directory" ]; then
echo "Directory '$directory' already exists."
else
echo "Directory '$directory' does not exists."
mkdir -p "$directory"
echo "Directory '$directory' created successfully."
fi
#OUTPUT
#CODE
if [ $# -eq 0 ]; then
echo "Usage: $0 file_path"
exit 1
fi
file_path="$1"
if [ -f "$file_path" ]; then
echo "File '$file_path' exists."
else
echo "File '$file_path' does not exist."
fi
#OUTPUT
#CODE
file_path="ide.txt"
if [ ! -f "$file_path" ]; then
echo "File '$file_path' does not exist."
exit 1
fi
#FILE
#OUTPUT
#CODE
append_data() {
local file="$1"
local data="$2"
if [ ! -f "$file" ]; then
echo "File '$file' does not exist."
return 1
fi
if [ ! -f "$file" ]; then
echo "File '$file' does not exist."
return 1
fi
rm "$file"
echo "File '$file' deleted."
}
if [ $# -eq 0 ]; then
echo "Usage: $0 file1 [file2 ...] data"
exit 1
fi
data="${@: -1}"
delete_file "$filename"
done
#FILES
#OUTPUT
#FILES
#CODE
if [ $# -eq 0 ]; then
echo "Usage: $0 file_path"
exit 1
fi
file_path="$1"
if [ ! -f "$file_path" ]; then
echo "File '$file_path' does not exist."
exit 1
fi
#OUTPUT
#FILE
#CODE
current_user=$(whoami)
file_count=$(find . -maxdepth 1 -type f -user "$current_user" | wc -l)
#OUTPUT