Link to home
Start Free TrialLog in
Avatar of ugeb
ugebFlag for United States of America

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

Avatar of sunnycoder
sunnycoder
Flag of India image

Hi ugeb,

There should be no space on either side of =

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

Cheers!
Sunnycoder
Avatar of ugeb

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

ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial