Function name as a number?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Function name as a number?
# 1  
Old 12-12-2013
Function name as a number?

i have this function that would print out the number "5" in an lcd format. I want to match it to the number 5 so when someone inputs the number 5, this function would be called

Code:
function five () {
    r=$1
    c=$2
    tput cup $r $((c+1))
    echo -ne '\u2500'
    tput cup $((r+1)) $((c))
    echo -ne '\u2502'
    tput cup $((r+2)) $((c+1))
    echo -ne '\u2500'
    tput cup $((r+3)) $((c+2))
    echo -ne '\u2502'
    tput cup $((r+4)) $((c+1))
    echo -ne '\u2500'
}

# 2  
Old 12-12-2013
For ksh you could put the function in your .kshrc along with alias 5=five
# 3  
Old 12-12-2013
oh sorry. this is for bash.
# 4  
Old 12-12-2013
Didn't think \u was supported in bash echo - still function and alias should work just use .bashrc
# 5  
Old 12-12-2013
thanks will try that. Smilie
# 6  
Old 12-12-2013
Quote:
Originally Posted by Chubler_XL
Didn't think \u was supported in bash echo
Works for me in Bash 4.2
# 7  
Old 12-12-2013
Not in 4.1.10 :

Code:
$ echo $BASH_VERSION
4.1.10(4)-release
$ echo -e '\u2505'
\u2505

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Function - Make your function return an exit status

Hi All, Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition. #Body function1() { if then echo "exist" else echo "not exist" } #if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies

2. UNIX for Beginners Questions & Answers

How to find encapsulating function name from line number?

I am looking at a log file which just tells me the filename and the line number inside that file that has the Error. What I am interested is knowing the encapsulating function. For example, here are the contents of the log file Error: foo.file on line wxy Error: foo.file... (3 Replies)
Discussion started by: kaaliakahn
3 Replies

3. Shell Programming and Scripting

Will files, creaetd in one function of the same script will be recognized in another function?

Dear All. I have a script, which process files one by one. In the script I have two functions. one sftp files to different server the other from existing file create file with different name. My question is: Will sftp function recognize files names , which are created in another... (1 Reply)
Discussion started by: digioleg54
1 Replies

4. Shell Programming and Scripting

What is the maximum number of parameter we can pass to a shell script function?

what is the maximum number of parameter we can pass to a shell script function (8 Replies)
Discussion started by: alokjyotibal
8 Replies

5. AIX

function trace back and address to line number conversion

Hi, I am new to AIX and I am developing a small tool for our product which helps debug memory leaks etc. Q1)Is there a way in which i can get a function trace back as to the call (lets say malloc() )has been made in which file--> in which function. I tried using the #pragma options (... (0 Replies)
Discussion started by: Wkdunreal
0 Replies

6. Shell Programming and Scripting

Record the Signal Type or Number in Bash Trap function

In my Bash script I have an exit/cleanup function in a trap statement like: trap exitCleanup 1 2 3 6 15 25 Is there anyway to capture which signal # has occurred to record in a log file. Please note I am trying to avoid something like: trap 'mySignal=1; exitCleanup' 1 trap... (1 Reply)
Discussion started by: ckmehta
1 Replies

7. Shell Programming and Scripting

Adding Two Number With Expression Function

ai, i have one question about shell script regarding for "expr" function i have using this command "previous=`expr $previous + 1`" where previous value is 0001, but when the script running, the result appear as expr 1 + 1 = 2 not 0002. The result i need as expr 0001 + 0001 should be... (2 Replies)
Discussion started by: dinodegil
2 Replies

8. UNIX for Advanced & Expert Users

How to set a label/number for a function in a shells script

Can any one let me know like how cn i set an label or number for each function whihc are there in an shells script: for example cd /opt/qcom/test/ function1() function2() function3() ------- i ahe a script like this .now i want to count each of this function like 1, 2, 3,............... (3 Replies)
Discussion started by: lalitka
3 Replies

9. Shell Programming and Scripting

Passing global variable to a function which is called by another function

Hi , I have three funcions f1, f2 and f3 . f1 calls f2 and f2 calls f3 . I have a global variable "period" which i want to pass to f3 . Can i pass the variable directly in the definition of f3 ? Pls help . sars (4 Replies)
Discussion started by: sars
4 Replies

10. Shell Programming and Scripting

Re-usable function to parse csv files with different number of fields

Hi there, been pondering how to deal with this and hoping someone would give me an insight on this. I need help on creating a reusable bash funtion to parse csv files containing different number of fields (comma-seperated). My initial thought is to create function for each input csv file (20+... (2 Replies)
Discussion started by: jy2k7ca
2 Replies
Login or Register to Ask a Question