Hi all. Suppose I have the following function in an executable file named "HOLA":
------------------------
function hola { echo "Hola ${@}."; }
------------------------
In addition, suppose that I want to execute the file so I can input my name next to ./HOLA. I mean,
--------------------------
$ ./HOLA hugo esquivel
--------------------------
According to the function hola, the output would be:
--------------------------
Hola hugo esquivel.
--------------------------
My question is: how can I achieve this behaviour? Is possible?
Any help will be greatly appreciated!
PS: What I want is to create the command hola on a BASH shell (but through the executable).
To keep the forums high quality for all users, please take the time to format your posts correctly.
First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)
Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.
Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.
You are missing the () behind the function name. Also you have to call a function when you want to use it. Also you have to give the function all the parameters you give to the shell script too. I changed $@ to $* since $@ is some thing like
Rest is formatting. It is also usually good to have a shebang in the 1st line (that #!...) to tell which shell/interpreter you want to use for this script, and also a "exit 0" can't harm if you are going to check exit stati.
Function, how to define ?
Old bsh style, which is also Posix-standard =
the most generic.
or alternative (ksh, bash, ...)
Or mixed - only in bash = not so generic
Hello.
I need to write a command line interface that can be invoked either directly from the shell (command sub-command arguments), or as a shell that can process sub-commands.
i want to use bash auto completion for both scenarios.
example: lets say my CLI module is called 'mycli' and there... (5 Replies)
Hello senior members,
I am a fairly newbie here. I just want to ask one question that how can once create one's own command interpreter/ shell like bash in unix/linux.
I need to execute basic commands like pipes and i/o.
Any help in this matter ?? (3 Replies)
Hi,
Can someone help me with creating a bash shell script.
I need to create a script that gets a positive number n as an argument.
The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
Hey all,
I need to know how many lines of C code are in a source bundle. I have extracted the bundle and hence there is a big directory tree with C files everywhere.
So far I have something like:
find . -name "*.c" | grep \ ./*/*/*/*/*/*
obviously wrong, if someone could help me out... (3 Replies)
In OS X I'm currently writing a bash script that requires writing to preference file. I may eventually want to share it with users on other Unix-like OSs and would like to accommodate for that possibility ahead of time.
Most OS X applications save preferences in xml-format plist files. These... (4 Replies)
I'm trying to write a history feature to a very simple UNIX shell that will list the last 10 commands used when control-c is pressed. A user can then run a previous command by typing r x, where x is the first letter of the command. I'm having quite a bit of trouble figuring out what I need to do, I... (2 Replies)
Hi,
I am trying to write script to copy some files(/ppscdr/cdrp2p/temp/) from one directory to another directory using shell script. see the script below,
#!/bin/sh -f
dir_name=20061105
mkdir ${dir_name}
cd /ppscdr/cdrp2p/temp
pwd
cp p2p${dir_name}*.*... (4 Replies)
Hi everybody in the forum,
I want to create an empty file of say some 1MB ,i mean at the command line itself.How is this possible??????EEK! (4 Replies)