We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,397 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Bash script to generate output files,what went wrong

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
2
Contributors
1
Reply
3 Weeks
Discussion Span
4 Months Ago
Last Updated
3
Views
Question
Answered
jpreem
Newbie Poster
3 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Self-Answered as of 5 Months Ago

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

TylerD75
Newbie Poster
3 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.1113 seconds using 2.63MB