I have started a few days ago learning how to make scripts in shell. How can I make script thaht takes two arguments ( file name and some directory), if arguments are bad I want to make error alert and if they are correct I want to copy file in given directory? so far I made this:
#!/bin/bash if [ -d $1 ] ; then ??? done else echo $1 NOT DIRECTORY exit 1 fi
And separate I made a part for checking a file. How to put this together ?
#!/bin/bash if [ $# -ne 1 ] then echo "Use- $0 file" exit 1 fi if [ -f $1 ] then echo "$1 There is no file with that name" else echo "$1 There is no file with that name" fi
I am new to bash script so I would like to get some help.