vendredi 6 février 2015

if statement to compare sentences not working in tcsh

I need to get a little if statement into a script written in tcsh. I want to check if the first line of a certain file is a specific sentence. However I don't get the script to work:



#!/bin/tcsh

set infile=baca.nn

set firstline=`head -n 1 $infile`

if ( $firstline == "Creating new file : ./data/weights.dat ..." ) then
echo "Firstline is true"
else
echo $firstline
endif


What am I doing wrong? I get the Error:



if: Expression Syntax.

Aucun commentaire:

Enregistrer un commentaire