create script

i want to create a script that will aid in automating bash commands, such as making directories, changing permissions, moving files, etc...  

How do I do this?  I am under the impression I need to make an executable file that contains these commands, but what else needs to be done?  Is there some special syntax in the file or something else?  Any links, refrences, hints?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


# vi
---- -----


mkdir -p <directory>
chmod < permission> <directory>
mv <source path> <target path>
# chmod +x

Then you can run that script
# ./   <enter>


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

to create bash script you need to :

create file
edit file
first byte of file has to contain interpreter:
make file executable
chmod +x
run script

Sometimes you do not really have to use script you can use just command. For example chanage permitions for all *txt files to rwxrwxrwx in your home directory u can use command:

find /home/yourname -iname \*.txt -exec chmod 777 {} \;

I would use aliases for this rather that individual scripts. Edit .bashrc in your home directory and add any aliases you like. They wont  work until you open a new shell or run source .bashrc. A couple of examples that I use -
alias xe="chmod +x"
alias log="cd /var/log"
alias mes="less /var/log/messages"
alias erc ="vi ~/.bashrc;source ~/.bashrc"
xe myfile will make myfile executable. log will change to the /var/log directory etc. You can alias several comands by putting a ; between them. I would only use scripts for more complex tasks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.