wildcard in bash alias
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I want to write an alias as such:
alias add="java -jar vc.jar name"
Is there a way I can use a wildcard for name and thus only have to type:
add name - with name being any name of my choice? name being an argument.
bash
New contributor
cdhdds is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
3
down vote
favorite
I want to write an alias as such:
alias add="java -jar vc.jar name"
Is there a way I can use a wildcard for name and thus only have to type:
add name - with name being any name of my choice? name being an argument.
bash
New contributor
cdhdds is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I want to write an alias as such:
alias add="java -jar vc.jar name"
Is there a way I can use a wildcard for name and thus only have to type:
add name - with name being any name of my choice? name being an argument.
bash
New contributor
cdhdds is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I want to write an alias as such:
alias add="java -jar vc.jar name"
Is there a way I can use a wildcard for name and thus only have to type:
add name - with name being any name of my choice? name being an argument.
bash
bash
New contributor
cdhdds is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
cdhdds is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
cdhdds is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 4 hours ago
cdhdds
161
161
New contributor
cdhdds is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
cdhdds is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
cdhdds is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
I think you are looking for functions.
function add()
local name="$1"
java -jar vc.jar "$name"
Add this to your ~/.bashrc
or ~/.profile
and just call like this;
user@host$ add samplename
Alternatively you can trigger an alias expansion by adding a space or tab character at the end of the alias definition.
alias add='java -jar vc.jar '
(Note the space at the end of definition).
Then just call it normally;
user@host$ add samplename
It should work.
EDIT:
As pointed out by @kusalananda you can ommit the space and it will still work just fine.
3
The space at the end of the alias should not be needed.
– Kusalananda
3 hours ago
3
The space at the end of the alias is to trigger alias expansion of the next word. Infoo bar
, iffoo
is an alias ending with space, thenbar
is also checked for alias expansion.
– muru
3 hours ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
I think you are looking for functions.
function add()
local name="$1"
java -jar vc.jar "$name"
Add this to your ~/.bashrc
or ~/.profile
and just call like this;
user@host$ add samplename
Alternatively you can trigger an alias expansion by adding a space or tab character at the end of the alias definition.
alias add='java -jar vc.jar '
(Note the space at the end of definition).
Then just call it normally;
user@host$ add samplename
It should work.
EDIT:
As pointed out by @kusalananda you can ommit the space and it will still work just fine.
3
The space at the end of the alias should not be needed.
– Kusalananda
3 hours ago
3
The space at the end of the alias is to trigger alias expansion of the next word. Infoo bar
, iffoo
is an alias ending with space, thenbar
is also checked for alias expansion.
– muru
3 hours ago
add a comment |Â
up vote
3
down vote
I think you are looking for functions.
function add()
local name="$1"
java -jar vc.jar "$name"
Add this to your ~/.bashrc
or ~/.profile
and just call like this;
user@host$ add samplename
Alternatively you can trigger an alias expansion by adding a space or tab character at the end of the alias definition.
alias add='java -jar vc.jar '
(Note the space at the end of definition).
Then just call it normally;
user@host$ add samplename
It should work.
EDIT:
As pointed out by @kusalananda you can ommit the space and it will still work just fine.
3
The space at the end of the alias should not be needed.
– Kusalananda
3 hours ago
3
The space at the end of the alias is to trigger alias expansion of the next word. Infoo bar
, iffoo
is an alias ending with space, thenbar
is also checked for alias expansion.
– muru
3 hours ago
add a comment |Â
up vote
3
down vote
up vote
3
down vote
I think you are looking for functions.
function add()
local name="$1"
java -jar vc.jar "$name"
Add this to your ~/.bashrc
or ~/.profile
and just call like this;
user@host$ add samplename
Alternatively you can trigger an alias expansion by adding a space or tab character at the end of the alias definition.
alias add='java -jar vc.jar '
(Note the space at the end of definition).
Then just call it normally;
user@host$ add samplename
It should work.
EDIT:
As pointed out by @kusalananda you can ommit the space and it will still work just fine.
I think you are looking for functions.
function add()
local name="$1"
java -jar vc.jar "$name"
Add this to your ~/.bashrc
or ~/.profile
and just call like this;
user@host$ add samplename
Alternatively you can trigger an alias expansion by adding a space or tab character at the end of the alias definition.
alias add='java -jar vc.jar '
(Note the space at the end of definition).
Then just call it normally;
user@host$ add samplename
It should work.
EDIT:
As pointed out by @kusalananda you can ommit the space and it will still work just fine.
edited 3 hours ago
answered 4 hours ago
cevhyruz
6819
6819
3
The space at the end of the alias should not be needed.
– Kusalananda
3 hours ago
3
The space at the end of the alias is to trigger alias expansion of the next word. Infoo bar
, iffoo
is an alias ending with space, thenbar
is also checked for alias expansion.
– muru
3 hours ago
add a comment |Â
3
The space at the end of the alias should not be needed.
– Kusalananda
3 hours ago
3
The space at the end of the alias is to trigger alias expansion of the next word. Infoo bar
, iffoo
is an alias ending with space, thenbar
is also checked for alias expansion.
– muru
3 hours ago
3
3
The space at the end of the alias should not be needed.
– Kusalananda
3 hours ago
The space at the end of the alias should not be needed.
– Kusalananda
3 hours ago
3
3
The space at the end of the alias is to trigger alias expansion of the next word. In
foo bar
, if foo
is an alias ending with space, then bar
is also checked for alias expansion.– muru
3 hours ago
The space at the end of the alias is to trigger alias expansion of the next word. In
foo bar
, if foo
is an alias ending with space, then bar
is also checked for alias expansion.– muru
3 hours ago
add a comment |Â
cdhdds is a new contributor. Be nice, and check out our Code of Conduct.
cdhdds is a new contributor. Be nice, and check out our Code of Conduct.
cdhdds is a new contributor. Be nice, and check out our Code of Conduct.
cdhdds is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471474%2fwildcard-in-bash-alias%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password