#!/bin/bash FILE=$1 FOLDER="$HOME/Trash" ARGS=1 if [ $# -ne $ARGS ] then echo "Error: You are missing an argument!" echo "Usage: ./trash.sh <file_name>" else if [ -s $FILE ] then if [ -d $FOLDER ] then mv -v $FILE $FOLDER else mkdir $FOLDER mv -v $FILE $FOLDER fi else echo "The file you have entered does not exist!" fi fi
Now, I want to extend my script in the followign ways, but I don't know how, because I am not that much experienced with bash scripting. First of all, I want to let the user enter more than one parameters, simply more then one file name, and move all the files in the Trash folder. If one or more of the files don't exist, it will inform the user which file or files don't exist. Simply, I want my script to recieve as many parameters as the user wants.
For example, if the user calls the script like this:
./trash.sh file1 file2 file3
and let's say that file2 doesn't exist I want the output to be.
file1 -> /home/user/Trash/file1 file3 -> /home/user/Trash/file3 file2 doesn't exist!
And lastly, I also want it to accept a parameter like this:
Simply, which will move all the files that end with .txt extension. If someone could help me achieve those things/extend my script, I would be glad.