Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
using if statements
Write a script (called q2.sh) that will take three arguments and make sure that three arguments are input. You need to check if they are files (report an error if they are a directory). Then you need to output the character count of each file and the total character count.

bash q2.sh 1.txt 2.txt 3.txt 
1.txt=23 2.txt=12 3.txt=8
Total number of characters is 43. ← Not bold: what your script might output


What I have tried:

Kindly write the code according to the instruction
Posted
Updated 6-May-22 1:15am

You have to write the script.
That said, for your script you need to know how to:
  • Detect an empty variable
  • Check if the file exists
  • Use the wc Linux command
Google is awaiting for you...
 
Share this answer
 
Comments
Patrice T 7-May-22 14:06pm    
+5
CPallini 9-May-22 2:00am    
Thank you.
Quote:
Kindly write the code according to the instruction


It doesn't quite work like that.
We do not do your work for you.
If you want someone to write your code, you have to pay - I suggest you go to Freelancer.com and ask there.

But be aware: you get what you pay for. Pay peanuts, get monkeys.

The idea of "development" is as the word suggests: "The systematic use of scientific and technical knowledge to meet specific objectives or requirements." BusinessDictionary.com[^]
That's not the same thing as "have a quick google and give up if I can't find exactly the right code".
So either pay someone to do it, or learn how to write it yourself. We aren't here to do it for you.
 
Share this answer
 
All the information you need is at bash(1): GNU Bourne-Again SHell - Linux man page[^].
 
Share this answer
 
The only code you get is the code YOU write.

Asking other people to do your work for you is insulting - yourself. It tells everyone you don't want to learn and that's the one skill you absolutely MUST have when working with code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900