Storing variable in Bash
White Hat
pigskin_referee at yahoo.com
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.
#!/usr/local/bin/bash
declare -a fname
declare -i count
declare -i limit
fname=( `ls *.sh | tr '\n' ' '` )
count=${#fname[*]}
limit=0
while [ ${limit} -lt ${count} ]; do
echo ${fname[$limit]} | sed -e ``/.sh/s///''
# do something here
limit=$((limit+1))
done
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?
Thanks!
--
White Hat
pigskin_referee at yahoo.com
____________________________________________________________________________________
Get easy, one-click access to your favorites.
Make Yahoo! your homepage.
http://www.yahoo.com/r/hs
More information about the freebsd-questions
mailing list