lundi 2 septembre 2019

BASH: Using a continue in a for loop

As this is for work, I am unable to show my real example; but will a dummy example to explain my issue. I have a BASH script that runs the following command:

for name in $HOME/data/individual-*-lookup; do
    $name
done

However if name equals a certain attribute (e.g. John). I want the for loop to skip over this name. I have tried the following code; but it still seems to run all the options:

#! /bin/bash

for name in $HOME/data/individual-*-lookup; do  
    if ["$name" == "$HOME/data/individual-john-lookup"]; then
        continue
    fi
    $filename

done

Aucun commentaire:

Enregistrer un commentaire