Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

grep ONLY a word in ksh

Avatar of sminfo
sminfo asked on
Shell Scripting
14 Comments1 Solution819 ViewsLast Modified:
Couple of questions in ksh:

1.How can I grep exactly a word or string  using grep?

Example: I want to grep ONLY FULL 'string1' after lsrole command output, but ONLY grep exactly 'string1'. I want to grep fails if 'string' or 'stri' or 'stgrin' is passed.

lsrole ALL|grep '^string1'

desired output:
string1 blah blah

2. How to do an 'echo' AND 'exit' if lsuser command fails? (NOTE: I'd like to hide stdout or stderr)
Example:

lsuser -a $user >/dev/null 2>&1 || (echo "Usuario no valido en el sistema. Abortando." && exit 1)