LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-21-2010, 03:11 PM   #1
erora
LQ Newbie
 
Registered: Jan 2010
Posts: 4

Rep: Reputation: 0
Unable to declare a variable in Cygwin


I recently installed Cygwin on my windows vista to practice on Linux\unix commands.
I am unable to do a simple task of declaring variables on the command prompt
I am trying:

$ vech=Bus
$ echo $vech

bash: vech : command not found
What am I missing? Do i need to add something to .bashrc?

Also, I remember right click on the shell command gives the ability to copy or paste text from the shell. I am using Bash, how do I copy n paste text on shell window?
Thanks much
 
Old 01-21-2010, 03:17 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 164Reputation: 164
(You shouldn't have to do this, but I don't have cygwin handy to do testing on) try:
Code:
export vech=Bus
echo $vech
 
Old 01-21-2010, 03:19 PM   #3
erora
LQ Newbie
 
Registered: Jan 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Hey rweaver,
Thanks. It worked. But why do I need to export the same?
Bash shell does not demand all variables to be exported while being declared.

Lemme know if you figure it out
Thanks again
 
Old 01-21-2010, 03:26 PM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
What you typed should work.
The export command takes a variable and exports it to the environment. About the only option you make when installing Cygwin is to use Unix newlines instead of MS's enter / newline pair. I always go for Unix returns do I don't have to run "dos2unix" before transfering to a Unix or Linux machine. If you have MS style returns in scripts (e.g. create a script or makefile in Windows and copy then to Linux) they won't work in Linux.

To cut and paste you need to use the drop down menu for the upper left corner close button. Right click, select mark, make your selection and press 'enter' on your keypad. You paste from the menu. (maybe shift-menu) works but I don't remember.

At least "ctrl-R" works which allows you to recall previous commands.
 
Old 01-21-2010, 03:27 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
Lightbulb


Sorry, but did you type the '$' in front of the command. That is just the prompt for the regular user.

Enter in:
vech=Bus
echo $vech

without the dollar sign.

Last edited by jschiwal; 01-21-2010 at 03:29 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to declare a Global Variable in Kernel rheosiva Linux - Kernel 1 04-17-2009 12:55 AM
Unable to set environmental variable ssuhaib Linux - Newbie 2 04-08-2009 05:47 AM
Have you ever used cygwin, i've met a problem with the command stat from cygwin andy820303 Linux - Newbie 0 03-11-2009 03:37 AM
Declare variable in a script against a command shipon_97 Linux - Newbie 13 12-07-2007 03:17 AM
Where should I declare the global variable ahm_irf Linux - Kernel 5 05-11-2007 11:36 AM


All times are GMT -5. The time now is 03:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration