assign var with set=a[5] not working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting assign var with set=a[5] not working
# 8  
Old 12-14-2010
Edited post #6
R0H0N
# 9  
Old 12-14-2010
Here is what I see here,
Code:
$ basename `cat bp`
q[3]

$ a="$1"
a=: Command not found.

$ echo $a

Note : I did try setting set a="$1", as well

Thanks.

Last edited by Scott; 12-14-2010 at 03:14 AM..
# 10  
Old 12-14-2010
Code:
$ set a=`cat bp | basename`
$ echo $a

R0H0N
# 11  
Old 12-14-2010
I did try it, still it has an issue ... ( basename doesnt work in this fashion )
Code:
$ cat bp | basename
basename: missing operand
Try `basename --help' for more information.

Just FYI ( to keep it even simpler )
Code:
$ set var=a[5]
set: No match.

I believe unix thins [] to be as a range, I do not see a way to escape it either.

Thanks.

Last edited by Franklin52; 12-14-2010 at 04:34 AM.. Reason: Please use code tags
# 12  
Old 12-14-2010
Code:
$ set var="a[5]"

does it work?
R0H0N
# 13  
Old 12-14-2010
No it doesn't work here.
Code:
 $ set var="a[5]"
 $ echo $var
echo: No match.

Thanks.

Last edited by Franklin52; 12-14-2010 at 04:34 AM.. Reason: Please use code tags
# 14  
Old 12-14-2010
try:

Code:
$ set var="a[5]"
 $ echo "$var"

R0H0N
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Using read to assign value to bash variable not working

Hi, I am attempting to assign the output of the following command, to two bash variables, var1 and var2 using "read," but it doesn't seem to be working. # openstack hypervisor stats show | awk -F'|' 'NR==14{print $2,$3}' vcpus 92 # echo $? 0 # openstack hypervisor... (4 Replies)
Discussion started by: sand1234
4 Replies

2. Shell Programming and Scripting

Csh , how to set var value into new var, in short string concatenation

i try to find way to make string concatenation in csh ( sorry this is what i have ) so i found out i can't do : set string_buff = "" foreach line("`cat $source_dir/$f`") $string_buff = string_buff $line end how can i do string concatenation? (1 Reply)
Discussion started by: umen
1 Replies

3. Windows & DOS: Issues & Discussions

How to automatically set the DISPLAY var?

Hi all, Our users use Putty on Windows servers to log on to UNIX via SSH and run GUI applications. Is there a way to automatically get the display numbers from xming or Exceed (that are running on Windows) to set the DISPLAY var properly on UNIX? X11 forwarding is not an option. The closest I... (3 Replies)
Discussion started by: ejianu
3 Replies

4. Programming

assign array with a local var???

Hi all, I am just wondering is this (below code) valid in programming int xx = 10110; int i; long yy = {1,2,3,4,5,6,7,8,xx}; I compiled this using gcc will all working option successfully without getting any warning or error. I didn't see this kind of code in my past... (7 Replies)
Discussion started by: zing_foru
7 Replies

5. UNIX for Advanced & Expert Users

assign array with a local var???

topic moved to programming (0 Replies)
Discussion started by: zing_foru
0 Replies

6. Shell Programming and Scripting

how to create variables in loop and assign filename after set command?

Hi, does anybody knows how to manage, that the filenames are assigned to a variable in a loop afer getting them with set command in a ksh, like: set B*.txt i=1 c=$# x=$((c+1)) echo "$x" while ] ; do _ftpfile$i="$"$i echo "$_ftpfile$i" i=$((i+1)) done The first echo returns,... (2 Replies)
Discussion started by: spidermike
2 Replies

7. Shell Programming and Scripting

SSH script. (Assign $var to free cmd) ???

Running: GNU/Linux, 2.6.22.9-61.fc6 (hope that's the right info needed) I am trying give the amount of RAM and the % used. I am using free command. I am having some problems with this command code: 1)T = `free | grep Mem | awk '{print $2}'` F = `free | grep Mem | awk '{print $4}'`... (3 Replies)
Discussion started by: AngelFlesh
3 Replies

8. Shell Programming and Scripting

assign shell var output of cmd "wc"

how do I feed output of "wc" to a shell script variable "countBcp"? (2 Replies)
Discussion started by: devy
2 Replies

9. Shell Programming and Scripting

Difference between "set $<var>" and "set -- $<var>"

Hi pros, Could anyone tell me the actual difference between setting the positional parameters from the variable using the following commands? $ var="This is my question" $ set $var $ echo $1 --> 'This' $ echo $2 --> 'is' .... .... and $ var="This is my question" $ set --... (3 Replies)
Discussion started by: royalibrahim
3 Replies

10. Shell Programming and Scripting

assign value to variable is not working

Hi :) The next script campares two files File1-Line1 vs File2-Line1, File1-Line1 vs File2-Line2... only if line contains "AS-", if LineX is not in File2 writes in aux, but "valor" is allways=1 never changes! :confused: What is wrong? valor changes to 0 before break, after brake is again 1 ... (3 Replies)
Discussion started by: agustincm
3 Replies
Login or Register to Ask a Question