0

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
Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232

1 Answers1

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