wildcard in bash alias

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite
1












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.










share|improve this question







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.























    up vote
    3
    down vote

    favorite
    1












    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.










    share|improve this question







    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.





















      up vote
      3
      down vote

      favorite
      1









      up vote
      3
      down vote

      favorite
      1






      1





      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.










      share|improve this question







      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






      share|improve this question







      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.











      share|improve this question







      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.









      share|improve this question




      share|improve this question






      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.




















          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.






          share|improve this answer


















          • 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. In foo bar, if foo is an alias ending with space, then bar is also checked for alias expansion.
            – muru
            3 hours ago










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          cdhdds is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          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






























          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.






          share|improve this answer


















          • 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. In foo bar, if foo is an alias ending with space, then bar is also checked for alias expansion.
            – muru
            3 hours ago














          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.






          share|improve this answer


















          • 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. In foo bar, if foo is an alias ending with space, then bar is also checked for alias expansion.
            – muru
            3 hours ago












          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.






          share|improve this answer














          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.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          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. In foo bar, if foo is an alias ending with space, then bar is also checked for alias expansion.
            – muru
            3 hours ago












          • 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. In foo bar, if foo is an alias ending with space, then bar 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










          cdhdds is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          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.













           


          draft saved


          draft discarded














          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













































































          Comments

          Popular posts from this blog

          List of Gilmore Girls characters

          What does second last employer means? [closed]

          One-line joke