F
F
fokin_nikolay19892021-06-03 16:50:42
linux
fokin_nikolay1989, 2021-06-03 16:50:42

How to process the result of a command through grep?

Good day
Tell me how to process the result of the command

#/bin/bash
error = $(sudoedit -s / | grep ...не знаю как написать что бы результат вывел   ;/  )
error2 = ;/
if error == error2 
then
........

sudoedit -s / -opens the editor, maybe it's worth checking if it opens or not? I don't understand how to do it

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor Taran, 2021-06-03
@fokin_nikolay1989

sudo -V | head -n 1 |awk '{ print $3 }'
conclusion

1.8.21p2

Now check the version
if [ "$(sudo -V | head -n 1 |awk '{ print $3 }')" = "1.8.21p2" ]; then
echo "все сработало"
fi

We complicate, as I understand it, you need to exclude certain versions, for this you will need to either make several if or elsif
if ; then 
  echo "все сработало 1.8.21p2"

elif ; then 
 echo "все сработало 1.0"

fi

If you clearly understand what you want, then you can do it in 1 line ,
for example
. If not this, and not this, then
describe what you want, for example, if this is a version above a certain one, then there may be problems because there are already letters inside

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question