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

LVL 11
ugebAsked:
Who is Participating?
 
sunnycoderCommented:
You do not need set

V=`echo $filename | awk 'BEGIN {FS="/"} {print substr($0,1,length($0)-4) "4.pro"}'`
echo  $V
0
 
sunnycoderCommented:
Hi ugeb,

There should be no space on either side of =

Cheers!
Sunnycoder
0
 
sunnycoderCommented:
> set V = $filename
          V=$filename
          ^^^ Note there are no spaces on either side of =

Cheers!
Sunnycoder
0
 
ugebAuthor Commented:
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

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.