Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
As you can see from the responses you have been given. Your lack of being specific got varied input. I suggest that you look at 'How to Ask Questions the Smart Way' so in the future your queries provide information that will aid us in diagnosis of the problem or query. That way you will receive targeted responses.
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;
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
bash: ungaunga: command not found
# advcomm ungaunga b
# ungaunga
mah monkey
#
/src
Code:
#!/bin/bash
case "$2" in
"b") chmod +x $1 && cp $1 /dir/to/scripts/bash/;;
"c") cp $1 /dir/to/scripts/c/;;
"p") cp $1 /dir/to/scripts/perl/;;
"py") chmod +x $1 && cp $1 /dir/to/scripts/python/;;
"r") cp $1 /dir/to/scripts/ruby/;;
"l") cp $1 /dir/to/scripts/lua/;;
*) echo -e "\nusage: `basename $0` sets command as callable\n: b bash : c C : p perl : py python : r ruby : l lua : \n";;
Last edited by cin_; 07-23-2011 at 09:03 AM.
Reason: gramm'err
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.