0
votes

It's boring to run java commande using java -jar arg1 arg2 .. Is there a way to create a standard command line easily from a script file, without alias ?
For instance using /usr/bin/trimmomatic to replace

java -jar /PROGS/EXTERN/trimmomatic-0.35.jar MYFILE 

by

trimmomatic MYFILE
1
Please see what does an alias does in bash tldp.org/LDP/abs/html/aliases.html - Inian
There are multiple answers on SO for similar questions, like this stackoverflow.com/questions/12397508/… and this stackoverflow.com/questions/19647744/… - Inian
I wasn't clear sorry. I m asking if it's possible to do this using a bash script file. For instance /usr/bin/trimmomatic - dridk

1 Answers

0
votes

You can append the following to your ~/.bashrc file:

alias trimmomatic='java -jar /PROGS/EXTERN/trimmomatic-0.35.jar'

Then restart your shell (or do source ~/.bashrc if you don't want to restart it) and the alias should be available.

Alternatively, you can define a bash function (e.g. in your ~/.bashrc again):

trimmomatic() { java -jar /PROGS/EXTERN/trimmomatic-0.35.jar "$@"; }

or a wrapper shell script that you can put in you $PATH:

#!/bin/bash
java -jar /PROGS/EXTERN/trimmomatic-0.35.jar "$@"