dimanche 6 juin 2021

Checking if a file that starts with letters exists [duplicate]

I have to write a bash script which has to check if a file that starts with letters a-m exists. If so, the detailed information about those files, which also have the .dat extension, needs to be entered into a file named 'info.txt', if not, sth else has to happen (I already wrote - it is ok).

The problem is with the first part - I get "bash: [: too many arguments" every time.

if  [ test -f [a-m]* ]; 
then 
  if [ test -f *.dat ];
    then
    -l > info.txt
else 
   BLABLA
fi
fi

Aucun commentaire:

Enregistrer un commentaire