0

This is a general question on the use of alias command in linux, but I will take with a mathematica example to be more clear. I want to creat an alias for mathematica run. The mathematica run command for a mathematica file myfile1.m is

math -run "<<myfile1.m"

Now if I put this whole command as an alias in bashrc like

alias m='math -run "<<myfile1.m"'

it will run the file when I just type m in terminal. But I want to know whether there is a way to use in the following way so that it could be used for any mathematica file run in a more sophisticated way :

alias m='math -run "<<file.m? "'

so that from the terminal I can run different mathematica files just typing

m myfile1.m

it will run

math -run "<<myfile1.m"

similarly for anyfile.m one just types

m anyfile.m

and it will run

math -run "<<anyfile.m"
BabaYaga
  • 457
  • 5
  • 20

2 Answers2

0

I'd suggest to do something like:

alias m='math -run'

so the command would look like

m "<<anyfile.m"

which is look better, as for me. If you'd like to get deeper, look into this: Link

Bandydan
  • 623
  • 1
  • 8
  • 24
  • Thanks for the link. But is it possible to use alias to do this? – BabaYaga Mar 06 '16 at 08:44
  • 1
    I think it is not, according to some articles and this question: http://stackoverflow.com/questions/7131670/make-bash-alias-that-takes-parameter Sorry, I can't try the functioning, I don't have linux close to me right now, but you can try @Goutam Das solution, maybe it will help. If you are interested in that, give me your contacts, and I will send you some bash books I have, really good ones. – Bandydan Mar 06 '16 at 08:51
  • so nice of you! Its really fun to dig these things! I will appreciate your help. You can send me at gkdgoutam@gmail.com – BabaYaga Mar 06 '16 at 09:01
  • Shared a google drive directory with bash books to email specified, please check email :) You are welcome. – Bandydan Mar 06 '16 at 10:07
0

With @Bandydan's suggestion the following seems to work.

function m() { math -run  "<<$@" ;}
BabaYaga
  • 457
  • 5
  • 20