Explain How ":=" works in shell scrpting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Explain How ":=" works in shell scrpting
# 1  
Old 02-16-2010
Explain How ":=" works in shell scrpting

Hi ,
can any one explain how in the below code ":=" working in shell programming.
Code:
 
L_DEBUG=${L_DBG:=N}
if [ ${L_DEBUG} = Y ]; then
  set -x
fi

Thanks
muddasas

Last edited by Scott; 02-16-2010 at 07:45 AM.. Reason: Code tags please...
# 2  
Old 02-16-2010
Hi.

I think the shell man page can explain it better than me Smilie

ksh description:
Quote:
${parameter:=word}
If parameter is not set or is null then set it to word; the value of the parameter is then substituted.
Positional parameters may not be assigned to in this way.
bash description:
Code:
${parameter:=word}
              Assign Default Values.  If parameter is unset or null, the expansion of word is assigned  to  parameter.
              The  value  of  parameter  is then substituted.  Positional parameters and special parameters may not be
              assigned to in this way.

# 3  
Old 02-16-2010
Quote:
Originally Posted by muddasani
Hi ,
can any one explain how in the below code ":=" working in shell programming.
Code:
 
L_DEBUG=${L_DBG:=N}
if [ ${L_DEBUG} = Y ]; then
  set -x
fi

Thanks
muddasas
Double post of:

https://www.unix.com/unix-dummies-que...es-syntax.html

Thread closed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Perl: Can someone please explain this code "sort { $a <=> $b } @unsorted"

@sorted = sort { $a <=> $b } @unsorted; I am having hard time understanding how this works? I know the output but interested to know the working. Thanks in advance. (2 Replies)
Discussion started by: Tanu
2 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. Red Hat

files having Script which works behind "who" & "w" commands

Dear All, plz print the path of files which have the script of "who" & "w" commands. thnx in advance. (6 Replies)
Discussion started by: saqlain.bashir
6 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

6. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

7. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

8. AIX

"too big" and "not enough memory" errors in shell script

Hi, This is odd, however here goes. There are several shell scripts that run in our production environment AIX 595 LPAR m/c, which has sufficient memory 14GB (physical memory) and horsepower 5CPUs. However from time to time we get the following errors in these shell scripts. The time when these... (11 Replies)
Discussion started by: jerardfjay
11 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

10. UNIX for Dummies Questions & Answers

No utpmx entry: you must exec "login" from lowest level "shell"

Hi I have installed solaris 10 on an intel machine. Logged in as root. In CDE, i open terminal session, type login alex (normal user account) and password and i get this message No utpmx entry: you must exec "login" from lowest level "shell" :confused: What i want is: open various... (0 Replies)
Discussion started by: peterpan
0 Replies
Login or Register to Ask a Question