Creating your own command in Linux
How can i create my own command in linux??
|
Hello,
You just have to code a program (bash, python, C, C++...) which does what you want Regards, Oliv' |
Hi and welcome to LQ.
The easiest way would be to use BASH. 1. Save your script somewhere in your path (the best place would probably be in ~/bin); 2. Make sure that directory is in your path. 3. make it executable (chmod +x myscript) 4. You are ready to go Is there any specific command you'd like to create? If you go the BASH way, this should be useful: http://tldp.org/LDP/abs/html/ |
|
I don't think he meant a SYSTEM CALL, Anisha :)
|
Many times newbies don't know what exactly they want, so it is better to enlighten them with other available options too!
|
when you say create you own command you need to be a little more clear. You can edit your bash files and create alias for commands or you can write a program and use that command. If you want to make a program then you need to learn some type of coding such as c, c++, python, perl, and many many more.
|
PATH=$PATH:/dir/to/scripts
Create the script.
Save copies of your scripts to a directory of your choosing. You can then add the directory of the scripts to your Path... Code:
# PATH=$PATH:/dir/to/scripts |
Thanks a lot guys!
|
Hi,
Welcome to LQ! Quote:
Just a few links to aid you to gaining some understanding. I would start at 4,5 &6 since your query requirements are aligned to these. While the other links will enhance your Gnu/Linux experience; 1 Linux Documentation Project 2 Rute Tutorial & Exposition 3 Linux Command Guide 4 Bash Beginners Guide 5 Bash Reference Manual 6 Advanced Bash-Scripting Guide 7 Linux Newbie Admin Guide 8 LinuxSelfHelp 9 Getting Started with Linux The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links! |
advent command
Once you have a directory for your homegrown commands you can try this...
I wrote a command that takes the project I am working on and makes it a callable command. I usually work in a different directory than the one I have appended to PATH so it has proved much easier to simply call this command instead of typing the entire path to my script directory. I like to keep the languages separate, and I bounce around a bit so I just added a second argument defining the type of script it is. Code:
# ungaunga Code:
#!/bin/bash |
All times are GMT -5. The time now is 11:18 PM. |