Link to home
Start Free TrialLog in
Avatar of sunilsagar
sunilsagar

asked on

shell script to verify brackets

Hi ,

I am trying to write a shell script to verify if brackets are used correctly in a file . If there is some other format it should show invalid.

Below are the correct formats :

[sunil:/1/2]
[sagar:/1/2/3/4]

Incorrect formats may have format :
[sunil:/1/2]]
[[sagar:/1/2]
[[sunil:/1/2/3]]

Please advise .
Avatar of Tintin
Tintin

if grep -qv "^\[[a-z].*[0-9]\]$" /path/to/your/file
then
      echo "File contains invalid characters"
fi

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Steven Vona
Steven Vona
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sunilsagar

ASKER

Thanks for quick Savone, it works !