BASH - Clearing value in a variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting BASH - Clearing value in a variable
# 1  
Old 11-08-2011
BASH - Clearing value in a variable

anyone has any idae how do i clear the value in a variable in BASH?

So far I come across "Clear-variable", however it can only clear a "Local" and "Global" variable. I'm trying to clear a self-declared variable.

Anyone has any suggestions?
# 2  
Old 11-08-2011
Code:
$ a="1234"
$ echo $a
1234
$ unset a
$ echo $a
 
$

# 3  
Old 11-08-2011
Thanks jay!
# 4  
Old 11-08-2011
You can set it to empty
Code:
a="1234"
$echo $a
1234
$ a=
$ echo $a
 
$

# 5  
Old 11-08-2011
Thanks for all your response!

But can i check with you guys, is it possible to clear the value in a 2d array with 2 variables as its value? E.g.
Code:
${a[$j$i]}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Clearing a environmental variable

i set a variable from the command line: export GANG="james,roy,martin" i can access this variable ($GANG) from a script. but each time i run the script, the variable keeps getting bigger. more info keeps getting added to it. Is there anyway i can make the $GANG variable contain the... (3 Replies)
Discussion started by: SkySmart
3 Replies

2. AIX

clearing PVID

HI admins, I am not able to clear pvid .I am getting below error. chdev -l hdisk273 -a pv=clear Method error (/usr/lib/methods/chgdisk): 0514-047 Cannot access a device. pv The disk is from SAN. I can clear remove the disk using rmdev.But if i run cfgmgr , this disk apperas... (2 Replies)
Discussion started by: newaix
2 Replies

3. AIX

log_file_system clearing script

Hi i need a script to manage the mount point for any log location (/u01/dump/log/) i need a script which removes files older then x days but it should not remove file with extention *.log, *.ora etc then for remaing files it must search the huge files like *.txt and do fuser <filename> and... (0 Replies)
Discussion started by: javeedkaleem
0 Replies

4. Shell Programming and Scripting

bash - Variable made of variable

Hello, I am struggling with using variable made using "eval". a=4 eval b$a=20 echo $b$a ??? As shown above, I am trying to call back the variable "bX" assuming I do not know the value of "a". How can I do that? I tried several combinations but nothing worked. Thanks (10 Replies)
Discussion started by: jolecanard
10 Replies

5. Shell Programming and Scripting

bash and ksh: variable lost in loop in bash?

Hi, I use AIX (ksh) and Linux (bash) servers. I'm trying to do scripts to will run in both ksh and bash, and most of the time it works. But this time I don't get it in bash (I'm more familar in ksh). The goal of my script if to read a "config file" (like "ini" file), and make various report.... (2 Replies)
Discussion started by: estienne
2 Replies

6. Linux

clearing history

Is it possible to clear certain specific commands from history. I mean not clearing the entire history (history -c). You don't want anyone to see a particular command you executed. must not also show you have cleared history. Is it possible ? (2 Replies)
Discussion started by: nitin09
2 Replies

7. Shell Programming and Scripting

passing variable from bash to perl from bash script

Hi All, I need to pass a variable to perl script from bash script, where in perl i am using if condition. Here is the cmd what i am using in perl FROM_DATE="06/05/2008" TO_DATE="07/05/2008" "perl -ne ' print if ( $_ >="$FROM_DATE" && $_ <= "$TO_DATE" ) ' filename" filename has... (10 Replies)
Discussion started by: arsidh
10 Replies

8. HP-UX

clearing history

HI, Can anybody tell me...what is a command for clearing command history in HP-UX machine. I tried 'history -c' but it is not applicable.... Thanks JAGDISH MACHHI (4 Replies)
Discussion started by: jagdish.machhi@
4 Replies

9. Filesystems, Disks and Memory

Clearing file contents

Hi, We need to clear the contents of a file. For this we tried using the commands like - '>filename' and 'cat filename > /dev/null'. If the file size is large, the above commands will clear the file contents but the size of the file remains the same (checked using the command 'ls -l... (6 Replies)
Discussion started by: raghukayyar
6 Replies

10. UNIX for Dummies Questions & Answers

Clearing Swapfiles?

Hi, Does anyone know of a command to safely clear the swapfiles to free up diskspace? It's done at shutdown/startup, but I'd rather not have down time, if possible. Thanks, MrToast (BTW, Mac OS X 10.3.5 ;) ) (3 Replies)
Discussion started by: MrToast
3 Replies
Login or Register to Ask a Question