Article 6E6NX bash script giving incorrect output. How can I correct this?

bash script giving incorrect output. How can I correct this?

by
brandnewcoat
from LinuxQuestions.org on (#6E6NX)
Hi, everyone.

I was hoping someone could clear something up for me. I have a sample code which I want to integrate into a bash script I'm teaching myself to write. So I have the following. It appears to be working but the output it gives is not correct:
Code:#! /bin/bash
C=$*
if
[ -d "$C" ] ; then
echo "$C is a directory";
elif [ -f "$C" ]; then
echo "$C is a file";
else
echo "$C is not valid";
exit
fiI give it a file and directory for output however it doesn't appear to be working...
Code:/home/user/Desktop/f.ile /home/user/Desktop is not validWould anybody be able to tell me why? shellcheck says its fine.
Thanks for reading and looking forward to your replies :-)
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments