Question

write a script that accepts for an input a single character or integer and checks if...

write a script that accepts for an input a single character or integer and checks if that character is present in the file in linux?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

Output:

input.txt file:

Raw Code:

#!/bin/bash

read character # Reading the character from user.
file="input.txt" # File name.

if grep -q $character $file # Checking if the given character is in the file.
   then echo "Word found."
else
   echo "Word not found."
fi

if you have any doubts plz ask in comment section.

Add a comment
Know the answer?
Add Answer to:
write a script that accepts for an input a single character or integer and checks if...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT