UNIX ONLY Write a bash script that will accept a filename as a command line argument. Your...

60.1K

Verified Solution

Question

Programming

UNIX ONLY

Write a bash script that will accept a filename as a commandline argument. Your script should first check whether the filenamehas been passed as argument or not (hint: at least one argument hasto be provided). If no argument has been provided your scriptshould display appropriate message and exit. If a file name hasbeen provided, your script should check if the file exists in thecurrent directory and display the contents of the file. Otherwiseif the file does not exist it should display an appropriate errormessage

WHAT WOULD THIS LOOK LIKE IN TERMINAL?

Answer & Explanation Solved by verified expert
4.4 Ratings (780 Votes)
bash32 vim fileexsitsshbinbashif ne 1 thenecho Illegal number of parametersexit 2fiFILE1if f FILE thenecho File FILE    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students