0

This question already has an answer here:

I am trying to identify system using systemd and glibc version 2.17 and then run specific set of code. This is what I have come out with but i get error

 ./testing.sh: line 4: [[UNIT: command not found

CODE:

#!/bin/sh
glib=`ldd --version | awk '/ldd/{print $NF}'`
ver=2.17
if [[`systemctl`=~-\.mount && $glib '==' $ver ]];then
echo "I have to execute certain specific stuff to glib ver 2.17"
fi

marked as duplicate by Gilles bash Sep 28 '16 at 22:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

Since you use the two [[ ]] test form, this is (or ksh), so :

#!/bin/bash

glib=$(ldd --version | awk '/ldd/{print $NF}')

if [[ $glib == 2.17 ]] && systemctl | grep -q '\.mount'; then
  echo "I have to execute certain specific stuff to glib ver 2.17"
fi

NOTE

  • use $( ) not `` in modern shell
  • place spaces around [[ and ]]
  • your regex try is better written with a

Not the answer you're looking for? Browse other questions tagged or ask your own question.