The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Both HOME and INSERT key send same escape sequence on ssh grossgermany UNIX for Dummies Questions & Answers 0 07-27-2007 07:12 PM
want to view the escape sequence sweta UNIX for Advanced & Expert Users 4 10-09-2006 10:20 AM
Available escape sequences Love SUN Solaris 6 06-20-2006 07:31 AM
Escape sequence puspendu Shell Programming and Scripting 4 02-08-2006 02:14 AM
What is "escape sequence" in tcsh on Solaris modemer UNIX for Advanced & Expert Users 2 02-15-2005 05:00 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-26-2008
shreekrishnagd shreekrishnagd is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 22
escape sequence for $

Hi all,
I have a requirement where the variable name starts with $, like
$Amd=/home/student/test/
How to work wit it? can some one help me, am in gr8 confusion
  #2 (permalink)  
Old 08-26-2008
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,864
Which shell, which language?

I don't think this is possible with sh/ksh/bash/awk/perl/php.
  #3 (permalink)  
Old 08-26-2008
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 699
Hi.
Quote:
name
A word consisting solely of letters, numbers, and underscores, and beginning with a letter or underscore. Names are used as shell variable and function names. Also referred to as an identifier.

-- excerpt from Bash Reference Manual
Note that the $ is not listed.

There is a way that the look of your requirement can be done -- essentially as an indirect assignment:
Code:
#!/bin/bash -

# @(#) z1       Demonstrate indirect assignment.

echo
a=0
b=1
a=b
echo " first assignment a = $a, b = $b"

echo
$a=2
echo " second assignment a = $a, b = $b"

echo
eval $a=2
echo " eval assignment a = $a, b = $b"

exit
Producing:
Code:
% ./z1

 first assignment a = b, b = 1

./z1: line 12: b=2: command not found
 second assignment a = b, b = 1

 eval assignment a = b, b = 2
However, in general, $ is used as the dereferencing operator in shells. In elementary perl, it must be used to identify scalar variables ... cheers, drl
  #4 (permalink)  
Old 08-26-2008
shreekrishnagd shreekrishnagd is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 22
Hi ... Mr.drl

I dint understand how ur solution could help me out in my requirment. If we have $ before any variable the flie throws an error message how to escape it....?????
  #5 (permalink)  
Old 08-26-2008
broli's Avatar
broli broli is offline
Registered User
  
 

Join Date: Dec 2007
Location: Argentina
Posts: 212
dont post the same thing twice
Usage of $ as variable name

go read the rules
  #6 (permalink)  
Old 08-26-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,382
so bottom line is you can't have a variable name starting with '$'???
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:42 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0