LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   How to identify if a dependency is already installed? (https://www.linuxquestions.org/questions/slackware-14/how-to-identify-if-a-dependency-is-already-installed-4175706086/)

slackuser222 01-09-2022 01:09 AM

How to identify if a dependency is already installed?
 
Hi everybody! I know it is a silly question, but someone could tell me if there is any simple way to identify if one dependency is already installed in my slackware system? I'm struggling to install Qgis, and it has more than 60 dependencies, according to Slackbuilds site... And I am pretty sure that at least some of then is already installed.

Another problem intrigues me... in some cases, when I try to install some pack, it gives me a error message related to the lack of some dependence. Then I install the dependence and try to install the pack again, and it returns me the same error, related to the lack of the same dependence... Why do it happen? just installing the dependence seems not be enough... I have noticed that in some cases, when it happens, the slackbuild script creates in /tmp a file with the name_of_the_pack.txz. Then I run installpkg over this .txz file, and this sometimes solves the issue, and sometimes doesn't... Is this correct?

I guess that in some cases is necessary to add some reference in the PATH variable, but I'm not sure with cases are those.

Thanks in advance.

imitis 01-09-2022 01:16 AM

for packages that have a lot deps I tend to use sbotools: https://pink-mist.github.io/sbotools/ it does checking and all.

slackuser222 01-09-2022 01:32 AM

Quote:

Originally Posted by imitis (Post 6316535)
for packages that have a lot deps I tend to use sbotools: https://pink-mist.github.io/sbotools/ it does checking and all.

Thank you! I'm trying right now another one, SBOpkg. Do you think it is somehow similar to the sbotools?

bormant 01-09-2022 02:31 AM

sbopkg -k ...
With -k sbopkg skips (i.e., doesn't process) any package it finds to be already installed.

chrisretusn 01-09-2022 05:04 AM

If I am not sure, I use "slackpkg search" or "slackpkg file-search". I sometimes just run with the build and see what is missing. That can be a bit time consuming, but once you have all the dependencies established the next set of build is a bit easier.

hazel 01-09-2022 06:01 AM

If the dependencies are linked libraries, you can find them easily by running ldd on the executable. You'll get a list of all the libraries it has linked to and the ones it couldn't find. Other kinds of dependencies are more tricky. If you're lucky, running the app from the terminal will yield an informative error message when something isn't found. If you're less lucky, you get a stupid message like "Something is missing":banghead:.

drgibbon 01-09-2022 06:13 AM

Quote:

Originally Posted by slackuser222 (Post 6316533)
I'm struggling to install Qgis, and it has more than 60 dependencies, according to Slackbuilds site...

With sbotools:
Code:

sboinstall qgis
With sbopkg you need to first generate a queue file with sqg, check out the docs with `man sqg`.

Gordie 01-09-2022 08:24 AM

1 Attachment(s)
I use sboui. It makes easier work for me of such complicated builds.

kjhambrick 01-09-2022 09:14 AM

Quote:

Originally Posted by slackuser222 (Post 6316533)
Hi everybody! I know it is a silly question, but someone could tell me if there is any simple way to identify if one dependency is already installed in my slackware system? I'm struggling to install Qgis, and it has more than 60 dependencies, according to Slackbuilds site... And I am pretty sure that at least some of then is already installed.

slackuser222 --

That's not really a Silly Q at all. If fact, it's essential to understand how Slackware Packages are Tracked to answer your Q.

There are lots of ways to tell if a package is installed on your Slackware System using the different Package Management Tools.

However, you can actially 'see for yourself' using /bin/ls, because for each installed package, there is a plain text file in /var/lib/pkgtools/packages/

For example, to see if postgis is installed, you could simply type from the command line:
Code:

$ ls -la /var/lib/pkgtools/packages/*postgis*

-rw-r--r-- 1 root root 6766 Jan  4 07:51 /var/lib/pkgtools/packages/postgis-3.1.2-x86_64-1_SBo

See below my sig ... I created a wrapper called ver which simplifies looking for packages as with wild-card names ( :) at least for me :) )

Note1: Speaking of dependencies ... /home/local/bin/ver depends on 2regex ( /home/local/bin/2regex )... below my sig ...

Now that I have /home/local/bin/ver , I can simply type ver some_package to see if I have it like so:
Code:

$ ver postgis

-rw-r--r-- 1 root root 6766 Jan  4 07:51 /var/log/packages/postgis-3.1.2-x86_64-1_SBo

So to see what's actually provided by the postgis package, you could look at the contents of the Package Manifest Text File:
Code:


$ cat /var/lib/pkgtools/packages/postgis-3.1.2-x86_64-1_SBo

PACKAGE NAME:    postgis-3.1.2-x86_64-1_SBo
COMPRESSED PACKAGE SIZE:    4.1M
UNCOMPRESSED PACKAGE SIZE:    31M
PACKAGE LOCATION: /tmp/postgis-3.1.2-x86_64-1_SBo.tgz
PACKAGE DESCRIPTION:
postgis: postgis (support for geographic objects in PostgreSQL)
postgis:
postgis: PostGIS adds support for geographic objects to the PostgreSQL
postgis: database. In effect, PostGIS "spatially enables" the PostgreSQL
postgis: server, allowing it to be used as a backend spatial database for
postgis: geographic information systems (GIS), much like ESRI's SDE or
postgis: Oracle's Spatial extension.
postgis:
postgis: http://postgis.org
postgis:
postgis:
FILE LIST:
./
install/
install/doinst.sh
install/slack-desc
<<snip>>

Note2: I am old and set in my ways ... until Slackware Current ( 15.0 ), Installed Package Manifest Files used to be in /var/log/packages/ which with Slackware 15.0, is now ( ? will be ? ) a SymLink pointing at /var/lib/pkgtools/packages/ and I've never bothered to change ver

Quote:

Another problem intrigues me... in some cases, when I try to install some pack, it gives me a error message related to the lack of some dependence. Then I install the dependence and try to install the pack again, and it returns me the same error, related to the lack of the same dependence... Why do it happen? just installing the dependence seems not be enough... I have noticed that in some cases, when it happens, the slackbuild script creates in /tmp a file with the name_of_the_pack.txz. Then I run installpkg over this .txz file, and this sometimes solves the issue, and sometimes doesn't... Is this correct?
I am afraid so ... and the tools depending on postgis have a few circular dependencies which requires that some of the packages be built and installed more than once !

Quote:

I guess that in some cases is necessary to add some reference in the PATH variable, but I'm not sure with cases are those.
I don't believe the PATH Variable will affect the dependency tree -- everything should land where it belongs.

One suggestion: after installing a REQUIRED Package, type: ldconfig

Quote:

Thanks in advance.
You're welcome and Hope this Helps more than it hurts :)

-- kjh

This /home/local/bin/ver

Code:

#!/bin/sh

PkgOnly=0
RetCode=0
NumErr=0

if [ "$1" = "-p" -o "$1" = "-b" ]
then
  PkgOnly=1
  shift
fi

for i in $(echo $@ |sed -e 's/,/ /g' -e 's/ and / /g')
do

  j="`2regex $i`"

  if [ "$PkgOnly" = "0" ]
  then
      ls -la /var/log/packages/*${j}* 2>/dev/null  ; RetCode=$?
  else
      for k in $(ls -1 /var/log/packages/*${j}* 2>/dev/null)
      do
        basename $k
      done
  fi

  [ "$RetCode" != "0" ] && NumErr=`expr $NumErr + 1`
 
done

[ "$NumErr" = "0" ] && exit 0

exit 1

This is /home/local/bin/2regex

Save it in your PATH and chmod 755 /path/to/2regex

Code:

#!/bin/sh
#
# 2regex command turns alpha to case-insensitive for ls
#
# B60318 - kjh added -lrspt options and help-text
#
PrgNam="`basename $0`"
DirNam="`dirname  $0`"

if [ "$DirNam" = "." ]
then
  if [ -f "$PrgNam" ]
  then
      DirNam="`pwd`"
  else
      DirNam="`whichone $PrgNam`"
      DirNam="`dirname $DirNam`"
  fi
elif [ "$DirNam" = ".." ]
then
  DirNam="`pwd`"
  DirNam="`dirname $DirNam`"
elif [ "`dirname $DirNam`" = ".." ]
then
  FooNam="`basename $DirNam`"
  DirNam="`pwd -P`"
  DirNam="`dirname $DirNam`/$FooNam"
elif [ "$DirNam" = "" ]              # should not happen ...
then                                  # see: man 3 dirname
  DirNam="`whichone $PrgNam`"
  DirNam="`dirname $DirNam`"
fi

AllArg="$@"
CwdDir="`pwd -P`"

AnchorLeft=0
AnchorRite=0
FixSpaces=0
AddPrefix=0
AddSuffix=0

WacExt ()
{
  echo "$@" |
  gawk '
  {
      if (( L = length( $0 )) < 1 )
      {
        print ""
        exit 0
      }
      for ( i = L ; i > 0 ; i -- )
      {
        if (( substr( $0, i,  1 ) == "." ) \
        &&  ( substr( $0, i-1, 1 ) != "/" ))
        {
            print substr( $0, 1, i-1 )
            exit 0
        }
      }
      print $0
      exit 0
  }'
  return $?
}
GetExt ()
{
  GetExtCase=""

  while [ "$1" = "-l" \
        -o "$1" = "-L" \
        -o "$1" = "-u" \
        -o "$1" = "-U" ]
  do
      if [ "$1" = "-l" -o "$1" = "-L" ]
      then
        GetExtCase="l"
        shift
      elif [ "$1" = "-u" -o "$1" = "-U" ]
      then
        GetExtCase="u"
        shift
      fi
  done

  echo "$@" |
  gawk '
  BEGIN {

      Case = "'"$GetExtCase"'" ""

  }
  function FixCase( DoCase, InStr )
  {
      if ( DoCase == "l" )
      {
        return( tolower( InStr ))
      }
      if ( DoCase == "u" )
      {
        return( toupper( InStr ))
      }
      return( InStr )
  }
  # main
  {
      if (( L = length( $0 )) < 1 )
      {
        print ""
        exit 0
      }
      for ( i = L ; i > 0 ; i -- )
      {
        if (( substr( $0, i,  1 ) == "." ) \
        &&  ( substr( $0, i-1, 1 ) != "/" ))
        {
            print FixCase( Case, substr( $0, i ))
            exit 0
        }
      }
      print ""
      exit 0
  }'
  return $?
}
Usage ()
{
  ErrNum=$1
  shift

  [ $# -gt 0 ] && echo -e "\n$*" >&2

  echo -e "\nusage:  $PrgNam [ -lrbps ] string" >&2
  cat  <<Usage_EOF >&2

Program $PrgNam converts a String to a Regular Expression suitable for ls
awk, grep or find.  Includes options to anchor the string left and right
and it can also convert each space to 'one-or-more-spaces'.
 
Options Include:

  -l - anchor left-side to Start of Line / Field

        example:  $PrgNam -l foo      -> '`$DirNam/$PrgNam -l foo`'

  -r - anchor right-side to End of Line / Field

        example:  $PrgNam -r bar      -> '`$DirNam/$PrgNam -r bar`'

  -b - translate each run of one-or-more spaces to '  *'

        example:  $PrgNam -b 'foo bar' -> '`$DirNam/$PrgNam -b 'foo bar'`'

  -p - Prefix string with a leading space REx

        example:  $PrgNam -p foo      -> '`$DirNam/$PrgNam -p baz`'

  -s - Append a space REx Suffix to string

        example:  $PrgNam -s bar      -> '`$DirNam/$PrgNam -s baz`'


Usage_EOF
 
  exit $ErrNum

}
while  getopts hspbrl junk 2>/dev/null
do
  case $junk in
      l)    AnchorLeft=1
            ;;
      r)    AnchorRite=1
            ;;
      b)    FixSpaces=1
            ;;
      p)    AddPrefix=1
            ;;
      s)    AddSuffix=1
            ;;
      h)    Usage 0
            ;;
      *)    Usage 1
            ;;
  esac
done

shift `expr $OPTIND - 1`

echo "$@" |
gawk '
BEGIN {

  AnchorLeft = "'"$AnchorLeft"'" +0
  AnchorRite = "'"$AnchorRite"'" +0
  FixSpaces  = "'"$FixSpaces"'"  +0
  AddPrefix  = "'"$AddPrefix"'"  +0
  AddSuffix  = "'"$AddSuffix"'"  +0
  #
  # portable ... runs on nawk or gawk
  #
  Lower = "abcdefghijklmnopqrstuvwxyz"
  Upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

  for ( i = 1 ; i <= length( Lower ) ; i ++ )
  {
      L = substr( Lower, i, 1 )
      U = substr( Upper, i, 1 )

      LoAry[L] = i
      UpAry[U] = i
      REAry[i] = "[" U L "]"
  }
  c = p = ""
}
# main
{
  OutStr = ( AnchorLeft == 1 ) ? "^" : ""

  if ( AddPrefix == 1 )
  {
      OutStr = OutStr " *"
      p = " "
  }
  for ( i = 1 ; i <= length( $0 ) ; i ++ )
  {
      if (( c = substr( $0, i, 1 )) in LoAry )
      {
        OutStr = OutStr REAry[ LoAry[c] ]
        p = c
        continue
      }
      if ( c in UpAry )
      {
        OutStr = OutStr REAry[ UpAry[c] ]
        p = c
        continue
      }
      if (( FixSpaces == 1 ) && ( c == " " ))
      {
        if ( p == " " )
        {
            continue
        }
        OutStr = OutStr "  *"
        p = c
        continue
      }
      OutStr = OutStr c
      p = c
  }
  if (( AddSuffix == 1 ) && ( p != " " ))
  {
      OutStr = OutStr " *"
  }
  if ( AnchorRite == 1 )
  {
      OutStr = OutStr "$"
  }
  print OutStr
}'


slackuser222 01-09-2022 11:46 AM

Quote:

Originally Posted by kjhambrick (Post 6316634)
slackuser222 --

That's not really a Silly Q at all. If fact, it's essential to understand how Slackware Packages are Tracked to answer your Q.

There are lots of ways to tell if a package is installed on your Slackware System using the different Package Management Tools.

However, you can actially 'see for yourself' using /bin/ls, because for each installed package, there is a plain text file in /var/lib/pkgtools/packages/

For example, to see if postgis is installed, you could simply type from the command line:
Code:

$ ls -la /var/lib/pkgtools/packages/*postgis*

-rw-r--r-- 1 root root 6766 Jan  4 07:51 /var/lib/pkgtools/packages/postgis-3.1.2-x86_64-1_SBo

See below my sig ... I created a wrapper called ver which simplifies looking for packages as with wild-card names ( :) at least for me :) )

Note1: Speaking of dependencies ... /home/local/bin/ver depends on 2regex ( /home/local/bin/2regex )... below my sig ...

Now that I have /home/local/bin/ver , I can simply type ver some_package to see if I have it like so:
Code:

$ ver postgis

-rw-r--r-- 1 root root 6766 Jan  4 07:51 /var/log/packages/postgis-3.1.2-x86_64-1_SBo

So to see what's actually provided by the postgis package, you could look at the contents of the Package Manifest Text File:
Code:


$ cat /var/lib/pkgtools/packages/postgis-3.1.2-x86_64-1_SBo

PACKAGE NAME:    postgis-3.1.2-x86_64-1_SBo
COMPRESSED PACKAGE SIZE:    4.1M
UNCOMPRESSED PACKAGE SIZE:    31M
PACKAGE LOCATION: /tmp/postgis-3.1.2-x86_64-1_SBo.tgz
PACKAGE DESCRIPTION:
postgis: postgis (support for geographic objects in PostgreSQL)
postgis:
postgis: PostGIS adds support for geographic objects to the PostgreSQL
postgis: database. In effect, PostGIS "spatially enables" the PostgreSQL
postgis: server, allowing it to be used as a backend spatial database for
postgis: geographic information systems (GIS), much like ESRI's SDE or
postgis: Oracle's Spatial extension.
postgis:
postgis: http://postgis.org
postgis:
postgis:
FILE LIST:
./
install/
install/doinst.sh
install/slack-desc
<<snip>>

Note2: I am old and set in my ways ... until Slackware Current ( 15.0 ), Installed Package Manifest Files used to be in /var/log/packages/ which with Slackware 15.0, is now ( ? will be ? ) a SymLink pointing at /var/lib/pkgtools/packages/ and I've never bothered to change ver



I am afraid so ... and the tools depending on postgis have a few circular dependencies which requires that some of the packages be built and installed more than once !



I don't believe the PATH Variable will affect the dependency tree -- everything should land where it belongs.

One suggestion: after installing a REQUIRED Package, type: ldconfig



You're welcome and Hope this Helps more than it hurts :)

-- kjh

This /home/local/bin/ver

Code:

#!/bin/sh

PkgOnly=0
RetCode=0
NumErr=0

if [ "$1" = "-p" -o "$1" = "-b" ]
then
  PkgOnly=1
  shift
fi

for i in $(echo $@ |sed -e 's/,/ /g' -e 's/ and / /g')
do

  j="`2regex $i`"

  if [ "$PkgOnly" = "0" ]
  then
      ls -la /var/log/packages/*${j}* 2>/dev/null  ; RetCode=$?
  else
      for k in $(ls -1 /var/log/packages/*${j}* 2>/dev/null)
      do
        basename $k
      done
  fi

  [ "$RetCode" != "0" ] && NumErr=`expr $NumErr + 1`
 
done

[ "$NumErr" = "0" ] && exit 0

exit 1

This is /home/local/bin/2regex

Save it in your PATH and chmod 755 /path/to/2regex

Code:

#!/bin/sh
#
# 2regex command turns alpha to case-insensitive for ls
#
# B60318 - kjh added -lrspt options and help-text
#
PrgNam="`basename $0`"
DirNam="`dirname  $0`"

if [ "$DirNam" = "." ]
then
  if [ -f "$PrgNam" ]
  then
      DirNam="`pwd`"
  else
      DirNam="`whichone $PrgNam`"
      DirNam="`dirname $DirNam`"
  fi
elif [ "$DirNam" = ".." ]
then
  DirNam="`pwd`"
  DirNam="`dirname $DirNam`"
elif [ "`dirname $DirNam`" = ".." ]
then
  FooNam="`basename $DirNam`"
  DirNam="`pwd -P`"
  DirNam="`dirname $DirNam`/$FooNam"
elif [ "$DirNam" = "" ]              # should not happen ...
then                                  # see: man 3 dirname
  DirNam="`whichone $PrgNam`"
  DirNam="`dirname $DirNam`"
fi

AllArg="$@"
CwdDir="`pwd -P`"

AnchorLeft=0
AnchorRite=0
FixSpaces=0
AddPrefix=0
AddSuffix=0

WacExt ()
{
  echo "$@" |
  gawk '
  {
      if (( L = length( $0 )) < 1 )
      {
        print ""
        exit 0
      }
      for ( i = L ; i > 0 ; i -- )
      {
        if (( substr( $0, i,  1 ) == "." ) \
        &&  ( substr( $0, i-1, 1 ) != "/" ))
        {
            print substr( $0, 1, i-1 )
            exit 0
        }
      }
      print $0
      exit 0
  }'
  return $?
}
GetExt ()
{
  GetExtCase=""

  while [ "$1" = "-l" \
        -o "$1" = "-L" \
        -o "$1" = "-u" \
        -o "$1" = "-U" ]
  do
      if [ "$1" = "-l" -o "$1" = "-L" ]
      then
        GetExtCase="l"
        shift
      elif [ "$1" = "-u" -o "$1" = "-U" ]
      then
        GetExtCase="u"
        shift
      fi
  done

  echo "$@" |
  gawk '
  BEGIN {

      Case = "'"$GetExtCase"'" ""

  }
  function FixCase( DoCase, InStr )
  {
      if ( DoCase == "l" )
      {
        return( tolower( InStr ))
      }
      if ( DoCase == "u" )
      {
        return( toupper( InStr ))
      }
      return( InStr )
  }
  # main
  {
      if (( L = length( $0 )) < 1 )
      {
        print ""
        exit 0
      }
      for ( i = L ; i > 0 ; i -- )
      {
        if (( substr( $0, i,  1 ) == "." ) \
        &&  ( substr( $0, i-1, 1 ) != "/" ))
        {
            print FixCase( Case, substr( $0, i ))
            exit 0
        }
      }
      print ""
      exit 0
  }'
  return $?
}
Usage ()
{
  ErrNum=$1
  shift

  [ $# -gt 0 ] && echo -e "\n$*" >&2

  echo -e "\nusage:  $PrgNam [ -lrbps ] string" >&2
  cat  <<Usage_EOF >&2

Program $PrgNam converts a String to a Regular Expression suitable for ls
awk, grep or find.  Includes options to anchor the string left and right
and it can also convert each space to 'one-or-more-spaces'.
 
Options Include:

  -l - anchor left-side to Start of Line / Field

        example:  $PrgNam -l foo      -> '`$DirNam/$PrgNam -l foo`'

  -r - anchor right-side to End of Line / Field

        example:  $PrgNam -r bar      -> '`$DirNam/$PrgNam -r bar`'

  -b - translate each run of one-or-more spaces to '  *'

        example:  $PrgNam -b 'foo bar' -> '`$DirNam/$PrgNam -b 'foo bar'`'

  -p - Prefix string with a leading space REx

        example:  $PrgNam -p foo      -> '`$DirNam/$PrgNam -p baz`'

  -s - Append a space REx Suffix to string

        example:  $PrgNam -s bar      -> '`$DirNam/$PrgNam -s baz`'


Usage_EOF
 
  exit $ErrNum

}
while  getopts hspbrl junk 2>/dev/null
do
  case $junk in
      l)    AnchorLeft=1
            ;;
      r)    AnchorRite=1
            ;;
      b)    FixSpaces=1
            ;;
      p)    AddPrefix=1
            ;;
      s)    AddSuffix=1
            ;;
      h)    Usage 0
            ;;
      *)    Usage 1
            ;;
  esac
done

shift `expr $OPTIND - 1`

echo "$@" |
gawk '
BEGIN {

  AnchorLeft = "'"$AnchorLeft"'" +0
  AnchorRite = "'"$AnchorRite"'" +0
  FixSpaces  = "'"$FixSpaces"'"  +0
  AddPrefix  = "'"$AddPrefix"'"  +0
  AddSuffix  = "'"$AddSuffix"'"  +0
  #
  # portable ... runs on nawk or gawk
  #
  Lower = "abcdefghijklmnopqrstuvwxyz"
  Upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

  for ( i = 1 ; i <= length( Lower ) ; i ++ )
  {
      L = substr( Lower, i, 1 )
      U = substr( Upper, i, 1 )

      LoAry[L] = i
      UpAry[U] = i
      REAry[i] = "[" U L "]"
  }
  c = p = ""
}
# main
{
  OutStr = ( AnchorLeft == 1 ) ? "^" : ""

  if ( AddPrefix == 1 )
  {
      OutStr = OutStr " *"
      p = " "
  }
  for ( i = 1 ; i <= length( $0 ) ; i ++ )
  {
      if (( c = substr( $0, i, 1 )) in LoAry )
      {
        OutStr = OutStr REAry[ LoAry[c] ]
        p = c
        continue
      }
      if ( c in UpAry )
      {
        OutStr = OutStr REAry[ UpAry[c] ]
        p = c
        continue
      }
      if (( FixSpaces == 1 ) && ( c == " " ))
      {
        if ( p == " " )
        {
            continue
        }
        OutStr = OutStr "  *"
        p = c
        continue
      }
      OutStr = OutStr c
      p = c
  }
  if (( AddSuffix == 1 ) && ( p != " " ))
  {
      OutStr = OutStr " *"
  }
  if ( AnchorRite == 1 )
  {
      OutStr = OutStr "$"
  }
  print OutStr
}'


I have no words to thank you for your answer, it was of an amazing help. The slackware community is the best one! Thank you very much!

drgibbon 01-09-2022 12:45 PM

@slackuser222, here's another way to search through your installed packages (multiple search terms with AND logic):
Code:

#!/bin/bash

## Search for installed Slackware packages

# set package dir
if [[ -d /var/lib/pkgtools/packages ]]; then
    # new Slackware package dir (15.0+)
    readonly lib=/var/lib/pkgtools/packages
else
    # old Slackware package dir
    readonly lib=/var/log/packages
fi

if [[ "$#" -eq 0 ]]; then
    # no search terms
    echo "Installed packages: $(find $lib -type f -maxdepth 1 -printf "%f\n" | wc -l)"
    exit 1
else
    # strip extra whitespace from arguments (xargs) and put into an array
    IFS=" " read -r -a array <<< "$(echo "$@" | xargs)"
    # prepend/append a backslash to each array element (for awk)
    array=( "${array[@]/#//}" )
    array=( "${array[@]/%//}" )
    # all terms to string
    search=${array[*]}
    # put ' && ' between each search term (for awk)
    search=$(echo "${search// / && }")
    # search (check case first)
    if [[ "$search" =~ [[:upper:]] ]]; then
        # case sensitive
        find "$lib" -type f -maxdepth 1 -printf "%f\n" | awk "$search"
    else
        # case insensitive
        find "$lib" -type f -maxdepth 1 -printf "%f\n" | awk "BEGIN{IGNORECASE=1} $search"
    fi
fi


kjhambrick 01-09-2022 01:51 PM

drgibbon --

Thanks for the script !

I need to play with it !!

-- kjh


All times are GMT -5. The time now is 04:30 AM.