Variable with hash character


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Variable with hash character
# 1  
Old 03-22-2011
Variable with hash character

Hi Experts,
I need to have a variable with value initialised to it.The value will possess a hash character with it.

ex: var=reports#2

so how I am suppose to do this?
# 2  
Old 03-22-2011

Just like that. What's the problem?

The # character is only special when it begins an unquoted word. In that case, use quotes:
Code:
var="reports #2"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Separate a hash variable into 2 parts in Perl

Dear Perl users/experts, Could somebody help me how to solve my problem, I have a hash variable that I want to convert into dot file (graphviz). I know how to convert it to dot file but I need some modification on the output of the hash variable before convert it to dot file. Eeach key of... (1 Reply)
Discussion started by: askari
1 Replies

2. Shell Programming and Scripting

Compare values of hashes of hash for n number of hash in perl without sorting.

Hi, I have an hashes of hash, where hash is dynamic, it can be n number of hash. i need to compare data_count values of all . my %result ( $abc => { 'data_count' => '10', 'ID' => 'ABC122', } $def => { 'data_count' => '20', 'ID' => 'defASe', ... (1 Reply)
Discussion started by: asak
1 Replies

3. Shell Programming and Scripting

In Perl can i define a hash with value as variable?

Hi, Is it possible in perl to have a hash defined with variables as theirs key values, like: %account = ('username' => 'boy', 'password' => $password); Thanks (1 Reply)
Discussion started by: zing_foru
1 Replies

4. Shell Programming and Scripting

Perl: accessing reference to variable inside hash.

Below is hash which contains reference to variables: my %mandatoryFields = ( 1 => \$msgtype, 2 => \$switchtype, 3 => \$card_nbr, 4 => \$natv_tran_type_code, 5 => \$amt_1 ); This... (0 Replies)
Discussion started by: som.nitk
0 Replies

5. UNIX for Advanced & Expert Users

Passing Hash variable in to sql query in perl

Hi Everyone, Can anyone help me how do i call hash variable in to sql query in perl. Please see the script below i have defined two Hash %lc and %tab as below $lc{'REFF'}='V_RES_CLASS'; $lc{'CALE'}='V_CAP_CLASS'; $lc{'XRPD'}='V_XFMR_CLASS'; $tab{'V_RES_CLASS'}='V_MFR_SERS';... (6 Replies)
Discussion started by: jam_prasanna
6 Replies

6. Shell Programming and Scripting

to save output of a command in hash variable

Hi all, is it possible to save the output of a unix command executed in perl to be saved in hash variable.. like i have the command `find $mypath ! -user mainuser -printf \"\%u \%h\\n\"`; this will print all the users other than mainuser with their paths. so is possible to capture... (2 Replies)
Discussion started by: saapa
2 Replies

7. UNIX for Dummies Questions & Answers

read a variable character by character, substitute characters with something else

im having trouble doing this: i have a variable with 2 characters repeating e.g. aababbbaaaababaabbaabbba is there a way i can search the variable for a's and b's and then change a's to b's and b's to a's? im guessing its like getting the 1's compliment of the string im doing this in... (2 Replies)
Discussion started by: vipervenom25
2 Replies

8. Shell Programming and Scripting

Perl: Pattern Matching a HASH variable

Hi All, I'm trying to test a Hash variable but it's not working. Here is my code - can anyone tell me if the test is valid? for (keys %enabled_yn) { if ($enabled_yn{$1} =~ m/\s+Y/) { $html =~ s/%(\w+)%/\<b\>\<font color\=orange\>$enabled_yn{$1}\<\/font\>\<\/b\>/g; }... (1 Reply)
Discussion started by: pondlife
1 Replies

9. Shell Programming and Scripting

How to create md5 Hash variable?

I have a script that runs the grub-md5-crypt command based on whether the pass_value variable is a non-zero string. The md5 hash is being created in the /opt/hostconfigs/$HOST file, but I can't echo $md5_value. It is blank. Is there a way to create and echo a md5 hash variable? if then... (1 Reply)
Discussion started by: cstovall
1 Replies

10. UNIX for Dummies Questions & Answers

Hash (#) as a variable

Hi I'm writing a cript that copies and renames files to a backup location. This script can be used in a "test" mode, whereby all the files that will be copied are listed. The problem is that the destination file will not yet exist, so I want to comment this part (I'm shure you'll see what I'm... (5 Replies)
Discussion started by: errolg
5 Replies
Login or Register to Ask a Question