Storing variable in Bash

White Hat pigskin_referee at
Tue Nov 20 11:10:31 PST 2007

I am attempting to write a script that will work on files stored in an array. The function is supposed to strip the files extension and then store the name of the file as a variable. This is what I have so far.

declare -a fname
declare -i count
declare -i limit

fname=( `ls *.sh | tr '\n' ' '` )

while [ ${limit} -lt ${count} ]; do
echo ${fname[$limit]} | sed -e ``/.sh/s///''
# do something here
What I want to do is store the file in a variable. I have tried this:
F_Name=echo ${fname[$limit]} | sed -e ``/.sh/s///''
As well as:
F_Name=( `echo ${fname[$limit]} | sed -e ``/.sh/s///''` )
along with several different variants of it, but without success. I continually receive an error message. Due to a particular situation, I cannot use 'basename' to accomplish this task.
Is there anyway that this can be done?
White Hat 
pigskin_referee at

Get easy, one-click access to your favorites. 
Make Yahoo! your homepage. 

More information about the freebsd-questions mailing list