So Im using our university servers through an ssh connection. I have a bunch of files in a directory which I would like to run through a perl script. So I thought this simple script I concocted should do the trick. I have used similar script on my home computer to do renaming of files (replace last line with mv $file $newfile) and it worked all-right. Alas when I use this on our uni server. Then it will produce error message :

./super: line 4: syntax error near unexpected token `newfile=`echo $file | sed 's/ehed/ehedp/'`'

Is it something to do with me opening a shell inside a remote ssh shell, etc? Should I quote something out even more :D.
Here is the script.

#!/bin/bash
for file in *.fa

newfile=`echo $file | sed 's/ehed/ehedp/'`
./4s.pl $file > $newfile
done

Edit: Oops, this was already solved it seems...
Try this:

for file in ( ls *.fa )
do
    newfile=$(echo $file | sed 's/ehed/ehedp/')
    ...etc...
done

Could work ;)

Martin

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.