jeudi 21 décembre 2017

Execute command and comapre it in a if statement

I am using bash scripting to check whether two specific directories are containing some specific number of files. lets assume 20. Is it possible to check it in a line inside a if statement?

#!/bin/bash

if [ [ls /path/to/dir1 | wc -l ] != 20 ||  [ ls /path/to/dir2 | wc -l ] != 50 ]; then
  echo "do this!"
elif
  echo "do that!"
fi

Aucun commentaire:

Enregistrer un commentaire