Lazer
Lazer

Reputation: 94820

How to create an alias that can substitute arguments for C shell?

I need to use the following very often

diff <filename.c> standard

How can I have an alias (adiff) for it so that I would do

adiff filename.c

and it would expand to

diff filename.c standard

Upvotes: 0

Views: 588

Answers (2)

Hans
Hans

Reputation: 158

Use diff's '--to-file' option.

Try adding this line to your .cshrc:

alias adiff '/usr/bin/diff --to-file=standard'

Just tested this in Bash (different alias-syntax though) and seems to work.

Please insert the full path for the file "standard" to make sure you can call it from other directories too.

Now you should be able to use:

$ adiff fromfile

Upvotes: 2

user472875
user472875

Reputation: 3175

Write a script and put it in your bin folder:

Read the first parameter of your script input and run diff <param1> standard

Upvotes: 0

Related Questions