🐧 Beginner bash script question
Nachrichtenbereich: 🐧 Linux Tipps
🔗 Quelle: reddit.com
Hello guys, I am new to bash scripts and I have a task to write a BASH Shell script that receives two parameters: filename and directory name. It should report an error if there are no two parameters or if the first is not a file or if the second is not a directory. If the parameters are correct, the script should copy the file to the specified directory.
This what I've done:
#!/bin/bash if [ "$#" -ne 2 ] then echo "Error!"; elif [ ! -f $1 ] echo "Error!"; elif [ ! -d $2 ] echo "Error!"; else cp $1 $2; fi
Is this okay? If not, can you tell me how should I correct it. Thank you in advance guys.
[link] [comments] ...
🐧 Beginner bash script question
📈 34.44 Punkte
🐧 Linux Tipps
🐧 Bash Script Include Another Bash Script
📈 32.45 Punkte
🐧 Linux Tipps
🐧 Bash / Perl beginner script help
📈 24.66 Punkte
🐧 Linux Tipps
🐧 VoidLinuxInstaller script, my first bash script!
📈 22.98 Punkte
🐧 Linux Tipps
🐧 BASH Scripting Question
📈 19.25 Punkte
🐧 Linux Tipps
🔧 bash coursera: intro shell bash scripting
📈 18.94 Punkte
🔧 Programmierung