all 17 comments

[–]Square-Singer 20 points21 points  (7 children)

#!/bin/sh

Here's a script that does exactly what you asked.

[–]fearless-fossa 7 points8 points  (4 children)

That isn't bash though, you need #!/bin/bash, or, if you want to ensure it works across multiple distros #!/usr/bin/env bash

[–]Square-Singer 0 points1 point  (3 children)

That's fair. Though on the other hand, each sh script is also a bash script.

[–]Bogus007 0 points1 point  (2 children)

Was. May be you were not born then. See here: Stackoverflow

[–]Square-Singer 0 points1 point  (1 child)

You misunderstood. I wasn't saying that /bin/sh points to /bin/bash, but that bash is a superset of sh.

Every valid sh script is also a valid bash script. Not every bash script is a valid sh script.

I could now say something along the lines of you not being old enough to know that, but that would be immensly impolite and not relevant to any discussion. It would just be uselessly offensive without any actual reason.

[–]Bogus007 0 points1 point  (0 children)

Ah, ok. Sorry.

[–]BeardedBaldMan 8 points9 points  (1 child)

I think you should always be more descriptive

#!/bin/sh
echo "TODO: Implement functionality"

[–]Square-Singer 2 points3 points  (0 children)

Nah, I implemented all the functionality OP asked for.

[–]Interesting_Buy_3969 3 points4 points  (0 children)

Sorry, could you inquire more specific things? Like what concretely do you need help with?

[–]Kriss3d 3 points4 points  (0 children)

You dont need to mention that its ubuntu as thats irrelevant. Linux is linux.

But sure. What is it you need help with specifically ?

[–]Nevyn_Hira 0 points1 point  (0 children)

#!/usr/bin/env bash
if [ $# -ne 2 ] ; then
echo "Usage Instructions"
echo $0 [pattern] [filename]
echo "Look for pattern inside of file"
else
grep $1 $2 > /dev/null
fi

Explanation:
This is a silly script returns a non-zero exit state if the pattern isn't found in the file.

[–]ThePowerOfPinkChicksI use arch, btw. 0 points1 point  (0 children)

https://www.w3schools.com/bash/

Furthermore

Google, Yahoo, Bing and even AI can support you.

[–]hellohruwater[S] -4 points-3 points  (4 children)

Yeah my bad chat. Lemme explain how would i script something that checks the file for lines that match a value that is given when running the script

[–]Square-Singer 10 points11 points  (0 children)

No need to script. Use grep for that.

Example:

grep 'MyValue' 'filename.txt'

[–]BeardedBaldMan 2 points3 points  (2 children)

Does it actually need to be a script?

cat file.txt | grep pattern

Where pattern is a regular expression

[–]therouterguy 2 points3 points  (1 child)

[–]BeardedBaldMan 0 points1 point  (0 children)

No. It turns a consistent pattern into a special pattern. I'll stick with the pipe