Skip to content
Advertisement

Tag: scripting

Bash scripting check condition

I’m new to bash scripting and trying to write the following simple And this works as expected. But if I delete echo “some string’ it prints nothing: Why? Why does deleting echo some_string right after the condition checking breaks the function? Answer It is because the if-condition is executed as a compound statement in bash i.e. command1;command2 and also incorrect

How do I search for a certain piece of text inside of a variable?

I am working on a script which prompts the user for their username. Once entered, the script uses the ‘rwho’ command to get a list of users who are logged into the network. It should crosscheck the text they entered (their username) with the results from the rwho command. If a match is found then it displays a message saying

Shell script doesn’t work when I export a variable inside it

I have a script called installscript which needs a change to the PATH variable. BuildScript file has the following code: Running ./BuildScript or source BuildScript fails with an error in installscript I have made a NewScript and call BuildScript from it after exporting the PATH variable running source NewScript works. I don’t understand why running BuildScript alone won’t work. Answer

Advertisement