how to find exact results from grep
My question is if i use a grep to find a statement from /etc/default/password
what coding should i need if /etc/default/passwd is 'passlength=' which is empty right after = because grep always takes the any stuff that matches it like 'passlength=2'. heres my coding if grep 'PASSLENGTH=' /etc/default/passwd then echo exception Yes else echo exception No fi Thanks in advance |
Assuming there's an end-of-line right after 'PASSLENGTH=', you can use
Code:
grep 'PASSLENGTH=$' ... |
Please use code tags around your codes. It preserves formatting and makes it easier to read.
Form the regex accordingly. I'm assuming passlength= starts on a new line and has nothing after it, ie: Code:
cat /etc/default/password Code:
grep "^passlength=$" /etc/default/password |
Thank you both of you. It works now.
|
Looking at your previous thread, you may want to read up on regex's. Here's a start:http://www.grymoire.com/Unix/Regular.html
|
Her's another link http://etext.lib.virginia.edu/servic...nix/regex.html
|
All times are GMT -5. The time now is 09:23 PM. |