Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to save simple commands

bob the spod
Occasional Advisor

how to save simple commands

I regularily have to copy a few files from one directory to the other using the below text

cp m_gload* /var/mgm/log

is there a way i can save this command and make it work by just typing a key word for example "reptile"

cheers

bob
you make me feel like dancing (gonna dance the night away!)
5 REPLIES
Pete Randall
Outstanding Contributor

Re: how to save simple commands

Bob,

Create an alias in your .kshrc or .shrc (whichever startup file you use, according to your shell):

alias spodcp="cp m_gload* /var/mgm/log"


Pete

Pete

Re: how to save simple commands

simply set an alias in your .profile:
alias reptile='cp m_gload* /var/mgm/log'

If I remeber correctly
then log out and back in, or reread you .profile by doing
cd
. ./.profile
alias
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
Donald Kok
Respected Contributor

Re: how to save simple commands

Hi Bob,
you can use the alias command like
alias psg="ps -ef | grep "

you can put this in a file which can be executed by .profile

HTH
Donald
My systems are 100% Murphy Compliant. Guaranteed!!!
bob the spod
Occasional Advisor

Re: how to save simple commands

thanks all you guys n gals

sorted!

knew it was possible but couldnt remember how

Happy Friday!
you make me feel like dancing (gonna dance the night away!)
Ian Dennison_1
Honored Contributor

Re: how to save simple commands

bob,

An alternative, which is also handy for directory names you can't remember easily, is to create a file in your home directory, with command commands and directories in it,...

eg.

# Start Sample file
exit 0

/var/opt/OV/monitors/OpC/customer/hp/hpux # opc script
/var/spool/cron/crontabs

/usr/lbin/modprpw -l -k # userid enable

# End Sample file

What I do if I can't remember the precise command or directory, is grep in the file for what I remember (eg cron or userid) and I get shown the matching lines, which I can then drag and drop into the command line.

I also have set up an environment variable on every HP-UX Server called DIRS, and use this alias when searching for files.

Share and Enjoy! Ian
Building a dumber user