Forum Moderators: bakedjake

Message Too Old, No Replies

making commands have certain options by default

         

scorpion

2:14 pm on Jun 22, 2003 (gmt 0)

10+ Year Member



Probably this is quite simple, but couldn't find the best strategic way to do this,

i.e.

when you type 'ls' you want the default to be 'ls -l'
is this a job for SYMBOLIC links or just best to create an executable perl script with a different name?

bartek

2:43 pm on Jun 22, 2003 (gmt 0)

10+ Year Member



What you're looking for is a command alias. Each shell is slightly different, but they're all pretty easy to set up.

For BASH, Bourne Again SHell, you need to edit the .bashrc file. As an example you could do:

alias del='rm -i'

Then you can use your "own" command:
del file.txt

hth

dingman

5:03 am on Jun 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For that matter, you can over-ride existing commands with alias. Alias ls='ls -l' if you like. In fact, the default on many systems is to alias ls to 'ls --color=auto' and rm to 'rm -i'. I personally find the latter extremely annoying, and always unalias rm so it behaves As God Intended. (ok, so in fact I currently have alias rm='wipe -fcs'. It still behaves As God Intended, only more so. ;))