Variable definition


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Variable definition
# 1  
Old 11-14-2013
Variable definition

Hi all,

I'm bit new to the advanced bash shell scripting.

When I'm looking at some of the existing code in my organization, got confused with a few variable definings.

For ex:
Code:
var1={1:-30}
var2="abc def ghi"
var3={xyz:-$var2}


In above, 1st and last lines are confusing me. Could anyone explain the meaning of it and how we can use those variable values please?

It would be very helpful if anyone suggest a brief guide or doc about advanced bash shell scripting.

Thnaks in advance.

Last edited by Scott; 11-18-2013 at 01:28 AM.. Reason: Code tags
# 2  
Old 11-14-2013
# 3  
Old 11-14-2013
See here

Example shows how it works :
Code:
A=30
B=40
echo ${A:-B} 
30
A=""
echo ${A:-B}
B
echo {A:-$B}
{A:-40}

# 4  
Old 11-17-2013
Thank you so much to both...

Those urls are having valuable info for me...

Thanks again for the explanation...
# 5  
Old 11-22-2013
This may help define a variable, in computer programmingSmilie I have read that it is a storage location and an associated symbolic name, an identifier which contains some known or unknown quantity or information, a value.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Variable definition inside mysql query

Hello, I am running ubuntu16.04. By means of @Rudic's help, I have below command. What I need to do is to replace video_id by value of video_id in which WHERE clause is matched: {print "INSERT INTO video_series_files (id, video_id, file_type, protocol, \ url, languages, quality, accessed... (12 Replies)
Discussion started by: baris35
12 Replies

2. UNIX for Dummies Questions & Answers

Environment variable definition

I'm a bit confused about the term ‘environment variables'. Within your shell you can set two types of variables: 1. Shell variable - affecting functionality within your shell 2. User defined variable When using the ‘export' command on a variable you make sure it's being inherited by new sub... (2 Replies)
Discussion started by: niels
2 Replies

3. Programming

Get struct definition

I have many headers with huge amount of structures in them, typical one looks like this: $ cat a.h struct Rec1 { int f1; int f2; }; struct Rec2 { char r1; char r2; }; struct Rec3 { int f1; float k1; float ... (6 Replies)
Discussion started by: migurus
6 Replies

4. What is on Your Mind?

Definition of Bytes

A byte is the smallest unit of storage which can be accessed in a computer's memory- either in RAM or ROM.It also holds exactly 8 bits.But its old view one byte was sufficient to hold one 8 bit character.Modern days especially on .NET or international versions of Win 32, 16 bits is needed. ... (2 Replies)
Discussion started by: stoudtLion
2 Replies

5. HP-UX

macro definition in FTP

Hi, I am trying to create a macro in FTP to rename multiple files.Below given is the codewhich i tried. I wanted to pass the files from the file "$FTPTXRENAMESUCLIST`" to the renfiles macro. Your help will be really appreciated. ftp -i -v -n << endftp > $FTPTXLOG 2> $FTPER open... (0 Replies)
Discussion started by: tinivt
0 Replies

6. Shell Programming and Scripting

How to define a variable with variable definition is stored in a variable?

Hi all, I have a variable say var1 (output from somewhere, which I can't change)which store something like this: echo $var1 name=fred age=25 address="123 abc" password=pass1234 how can I make the variable $name, $age, $address and $password contain the info? I mean do this in a... (1 Reply)
Discussion started by: freddy1228
1 Replies

7. UNIX for Dummies Questions & Answers

Definition of $-

Could someone please direct me to a link that gives the definitions for each of the letters from the results of the $- environment variable? It would be nice to know what shell options each of the letters represents, but I am specifically looking for the shell option for 'c' (lowercase c). Thank... (12 Replies)
Discussion started by: sszd
12 Replies

8. Shell Programming and Scripting

daemons definition

hi there, can somebody give me a definition for daemons, or example what are they !! and what the use for? i've done some research and all what i found is /etc/... or /usr/bin/... and i haven't quietly got the concept. any ideas !! Thanks. (5 Replies)
Discussion started by: new2Linux
5 Replies

9. Shell Programming and Scripting

What wrong with the variable definition

i am using the below script and trying to move files in that directory in that pattern to archive. But it doesn;t seem to take the metacharacters. Please sugggest. Code Debug output: (1 Reply)
Discussion started by: dsravan
1 Replies

10. UNIX for Dummies Questions & Answers

Definition of Concurrent Users

Can someone guide me in telling me what is a good definition of concurrent users. Is there a website I can go to to get this definition? (2 Replies)
Discussion started by: mpshaw
2 Replies
Login or Register to Ask a Question