I'm writing a simple script to change the file extension of a file. I won't lie, it's a homework assignment and I finally figured out how to get sed to behave in the way I expected but when running the program, I get: "Bad: modifier in $( )" if I specify a file that doesn't exist. How can I fix that? What I WANT to happen is that if the second argument is blank or the file doesn't exist, for it to go to the then portion of the if code.
Code:#!/bin/tcsh \ set fileExt="$1" set oldName="$2" if (-r $oldName) then set newName = `echo $oldName | sed 's/.$/'$fileExt/''` mv $oldName $newName else echo $oldName: No such file endif



LinkBack URL
About LinkBacks


