Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Scripts for commands?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Spacefreak
Tux's lil' helper
Tux's lil' helper


Joined: 16 Jan 2007
Posts: 76

PostPosted: Tue Jul 12, 2011 4:21 am    Post subject: Scripts for commands? Reply with quote

I'm not the most savvy Linux command prompt user, and my usual venture into said realm involves my good friend Google. That said, there are many commands that I have run throughout my system setup that I thought, this would be really useful to remember for later. Since I only ran them once though, obviously I don't remember them. I could keep a book of commands, or make a text file and list every command I thought was nifty. What I really want to know though, is whether or not it's possible to write a script to run certain commands?

So that instead of keeping a text file or trying to remember them, I can just make a directory broken down by task type with various scripts to do certain things when I need to do them. It would help me greatly.
Back to top
View user's profile Send private message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2152

PostPosted: Tue Jul 12, 2011 7:04 am    Post subject: Reply with quote

I don't quite get what you are trying to achieve, so sorry if I get it wrong and the following doesn't help you.

As I understood it, instead of ,for example, running 'mkdir some/directory' you would rather call it 'create_directory', so you can more easily remember it, but it achieves the same task?

If I got this right, then all you need is a script, most easily that would be in BASH. If that's the case, you've got two simple choices. Either define an alias in your ~/.bashrc, for example
Code:
alias my_command='what i would normaly type, but can't remember'
That would be the easiest way if you only need single or short commands.

If you want to achieve more complex things quite easily, create a bash script, that is
Code:
$EDITOR my_script
then, the first line should be
Code:
#!/bin/bash
and after that you can write all your wanted commands just as you need/want them.

Finally, do
Code:
chmod +x my_script
and then you can always execute it via
Code:
/path/to/my_script
.

If that's not what you want, please give a better explanation, if possible with some examples of what you'd like to achieve.
_________________
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
Back to top
View user's profile Send private message
Spacefreak
Tux's lil' helper
Tux's lil' helper


Joined: 16 Jan 2007
Posts: 76

PostPosted: Tue Jul 12, 2011 1:09 pm    Post subject: Reply with quote

That pretty much takes care of it. I just want to make a folder on my Desktop that has certain commands I can just execute by file name rather than look up the context and such. So, that solves it perfectly, thank you!
Back to top
View user's profile Send private message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2152

PostPosted: Tue Jul 12, 2011 1:33 pm    Post subject: Reply with quote

Your welcome :)

Don't forget, you can also assign shortcuts or create custom menus in your window manager/desktop environment. If your happy, please don't forget to add '[solved]' to the topics title, thanks.
_________________
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum