Bash way to tell if String is in String
env: SLES9 SP1 intell, KDE
Hi, I think I am in BASH, I am in the /etc/profile.local that I created, but I did not put #!/bin/bash at the top, so who knows what it is. Anyway, I want to export PATH with an appended dir in there. Problem is, I need to know if it is already appended, because it gets appended twice. So how would I do this? I have tried "expr index...", grep wants a file, must be a way. If someone could please post the actual code instead of speaking in vague abstractions, that would be great. A coworker gave me a huge example script involving large functions and arrays and a main, but isn't there an easy way. thanks, tongar |
Re: Bash way to tell if String is in String
Quote:
Code:
echo "$PATH" |grep <pattern> |
Quote:
But if you want it anyway, try this: Code:
DIR_TO_ADD="/example/dir/bin" |
thanks perfect_circle and Hko,
Hko, the code you suggest works fine. I read the man pages. It seems to indicate the etc/profile (which invokes etc/profile.local) would be the place for this. When I remove it from there I get no such dir in the PATH, when I put it in without your snippet, I get two after system startup and root login. thanks for the help, tongar |
All times are GMT -5. The time now is 02:33 PM. |