ugeb
asked on
using a shell variable in Cygwin (windows unix equivalent)
Hi,
I'm trying to set a variable in a Cygwin shell script. I try the following:
find . -name "*.pro" | while read filename
do
set V = $filename
set V = `echo $filename`
echo $V
echo ${V}
...
and I've tried a bunch of variations on the set theme, but the echo $V always gives a blank value.
How do I assign a variable in a script?
Thanks,
Gene
I'm trying to set a variable in a Cygwin shell script. I try the following:
find . -name "*.pro" | while read filename
do
set V = $filename
set V = `echo $filename`
echo $V
echo ${V}
...
and I've tried a bunch of variations on the set theme, but the echo $V always gives a blank value.
How do I assign a variable in a script?
Thanks,
Gene
> set V = $filename
V=$filename
^^^ Note there are no spaces on either side of =
Cheers!
Sunnycoder
V=$filename
^^^ Note there are no spaces on either side of =
Cheers!
Sunnycoder
ASKER
Hi,
Okay, I tried your suggestion:
1)
echo $filename | awk 'BEGIN {FS="/"} {print substr($0,1,length($0)-4) "4.pro"}'
2)
set V=`echo $filename | awk 'BEGIN {FS="/"} {print substr($0,1,length($0)-4) "4.pro"}'`
echo $V
#1 echos what I'm looking for, but #2 (when I'm trying to put it in a variable) doesn't. Is there some difference between Cygwin shell and unix shell maybe?
Thanks,
Gene
Okay, I tried your suggestion:
1)
echo $filename | awk 'BEGIN {FS="/"} {print substr($0,1,length($0)-4) "4.pro"}'
2)
set V=`echo $filename | awk 'BEGIN {FS="/"} {print substr($0,1,length($0)-4) "4.pro"}'`
echo $V
#1 echos what I'm looking for, but #2 (when I'm trying to put it in a variable) doesn't. Is there some difference between Cygwin shell and unix shell maybe?
Thanks,
Gene
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There should be no space on either side of =
Cheers!
Sunnycoder