.bashrc alias for a command with fixed second parameterHow to run some alias command in bash's non-interactive modeSaw an interesting command but can't alias itHow to alias one command to be resolved into another command?argument-aware alias command?Alias for gnome-open to open different filesCan I pass arguments to an alias command?Catch user input with aliasModify the “alert” alias in ~/.bashrcHow to set an Alias in bashrc so that System IP can be found using a simple alias command?Bash_alias, run a script with a parameter and close console

What is the best way to deal with NPC-NPC combat?

What to do with someone that cheated their way through university and a PhD program?

Drawing a german abacus as in the books of Adam Ries

All ASCII characters with a given bit count

As an international instructor, should I openly talk about my accent?

"My boss was furious with me and I have been fired" vs. "My boss was furious with me and I was fired"

How exactly does Hawking radiation decrease the mass of black holes?

Why do games have consumables?

What does "function" actually mean in music?

Are there moral objections to a life motivated purely by money? How to sway a person from this lifestyle?

How to pronounce 'c++' in Spanish

Multiple options vs single option UI

What is this word supposed to be?

Can a stored procedure reference the database in which it is stored?

What makes accurate emulation of old systems a difficult task?

Find a stone which is not the lightest one

How long after the last departure shall the airport stay open for an emergency return?

Is Diceware more secure than a long passphrase?

Is there really no use for MD5 anymore?

How can I practically buy stocks?

Crossed out red box fitting tightly around image

How do I deal with a coworker that keeps asking to make small superficial changes to a report, and it is seriously triggering my anxiety?

Mistake in years of experience in resume?

How to find if a column is referenced in a computed column?



.bashrc alias for a command with fixed second parameter


How to run some alias command in bash's non-interactive modeSaw an interesting command but can't alias itHow to alias one command to be resolved into another command?argument-aware alias command?Alias for gnome-open to open different filesCan I pass arguments to an alias command?Catch user input with aliasModify the “alert” alias in ~/.bashrcHow to set an Alias in bashrc so that System IP can be found using a simple alias command?Bash_alias, run a script with a parameter and close console






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I would like to create an alias for the move command -



trash='mv <some files> /home/$USER/.local/share/Trash/files'



How do I make this work?



I want the destination to always be the same. But I want to be able to pass the files to be moved.










share|improve this question

















  • 2





    There is already a command-line interface to the trash: in 18.04 it's gio trash (in earlier versions of Ubuntu, gvfs-trash) i.e. you can just type gio trash <some files>. If that's really too long then you can alias it alias trash='gio trash'.

    – steeldriver
    Apr 21 at 13:27

















3















I would like to create an alias for the move command -



trash='mv <some files> /home/$USER/.local/share/Trash/files'



How do I make this work?



I want the destination to always be the same. But I want to be able to pass the files to be moved.










share|improve this question

















  • 2





    There is already a command-line interface to the trash: in 18.04 it's gio trash (in earlier versions of Ubuntu, gvfs-trash) i.e. you can just type gio trash <some files>. If that's really too long then you can alias it alias trash='gio trash'.

    – steeldriver
    Apr 21 at 13:27













3












3








3


1






I would like to create an alias for the move command -



trash='mv <some files> /home/$USER/.local/share/Trash/files'



How do I make this work?



I want the destination to always be the same. But I want to be able to pass the files to be moved.










share|improve this question














I would like to create an alias for the move command -



trash='mv <some files> /home/$USER/.local/share/Trash/files'



How do I make this work?



I want the destination to always be the same. But I want to be able to pass the files to be moved.







bash






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 21 at 9:58









charsicharsi

18817




18817







  • 2





    There is already a command-line interface to the trash: in 18.04 it's gio trash (in earlier versions of Ubuntu, gvfs-trash) i.e. you can just type gio trash <some files>. If that's really too long then you can alias it alias trash='gio trash'.

    – steeldriver
    Apr 21 at 13:27












  • 2





    There is already a command-line interface to the trash: in 18.04 it's gio trash (in earlier versions of Ubuntu, gvfs-trash) i.e. you can just type gio trash <some files>. If that's really too long then you can alias it alias trash='gio trash'.

    – steeldriver
    Apr 21 at 13:27







2




2





There is already a command-line interface to the trash: in 18.04 it's gio trash (in earlier versions of Ubuntu, gvfs-trash) i.e. you can just type gio trash <some files>. If that's really too long then you can alias it alias trash='gio trash'.

– steeldriver
Apr 21 at 13:27





There is already a command-line interface to the trash: in 18.04 it's gio trash (in earlier versions of Ubuntu, gvfs-trash) i.e. you can just type gio trash <some files>. If that's really too long then you can alias it alias trash='gio trash'.

– steeldriver
Apr 21 at 13:27










3 Answers
3






active

oldest

votes


















9














Use function instead of alias, defined in .bashrc



nano ~/.bashrc 

# put inside .bashrc:
trash()
for item in "$@" ; do
echo "Trashing: $item"
mv "$item" /home/$USER/.local/share/Trash/files
done



Then in shell prompt you can use:



$ trash file1 file2





share|improve this answer























  • thanks! This worked perfectly.

    – charsi
    Apr 21 at 10:16











  • Don't forget to close shell and open again to make this work

    – LeonidMew
    Apr 21 at 10:16











  • source ~/.bashrc works too

    – charsi
    Apr 21 at 10:17







  • 5





    You don't need a loop: trash() mv "$@" destination;

    – glenn jackman
    Apr 21 at 14:34


















5














You can only append arguments to an alias. Fortunately, mv allows you to do this, with the -t option



alias trash='mv -t ~/.local/share/Trash/files'





share|improve this answer






























    0














    You can also create a bash script and run that script with an alias.



    trash.sh:



    #!/bin/sh

    for arg in $*; do
    mv $arg /home/$USER/.local/share/Trash/files
    done

    exit 0


    .bashrc:



    alias trash="/path/to/script/trash.sh"





    share|improve this answer























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "89"
      ;
      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',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1135728%2fbashrc-alias-for-a-command-with-fixed-second-parameter%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      9














      Use function instead of alias, defined in .bashrc



      nano ~/.bashrc 

      # put inside .bashrc:
      trash()
      for item in "$@" ; do
      echo "Trashing: $item"
      mv "$item" /home/$USER/.local/share/Trash/files
      done



      Then in shell prompt you can use:



      $ trash file1 file2





      share|improve this answer























      • thanks! This worked perfectly.

        – charsi
        Apr 21 at 10:16











      • Don't forget to close shell and open again to make this work

        – LeonidMew
        Apr 21 at 10:16











      • source ~/.bashrc works too

        – charsi
        Apr 21 at 10:17







      • 5





        You don't need a loop: trash() mv "$@" destination;

        – glenn jackman
        Apr 21 at 14:34















      9














      Use function instead of alias, defined in .bashrc



      nano ~/.bashrc 

      # put inside .bashrc:
      trash()
      for item in "$@" ; do
      echo "Trashing: $item"
      mv "$item" /home/$USER/.local/share/Trash/files
      done



      Then in shell prompt you can use:



      $ trash file1 file2





      share|improve this answer























      • thanks! This worked perfectly.

        – charsi
        Apr 21 at 10:16











      • Don't forget to close shell and open again to make this work

        – LeonidMew
        Apr 21 at 10:16











      • source ~/.bashrc works too

        – charsi
        Apr 21 at 10:17







      • 5





        You don't need a loop: trash() mv "$@" destination;

        – glenn jackman
        Apr 21 at 14:34













      9












      9








      9







      Use function instead of alias, defined in .bashrc



      nano ~/.bashrc 

      # put inside .bashrc:
      trash()
      for item in "$@" ; do
      echo "Trashing: $item"
      mv "$item" /home/$USER/.local/share/Trash/files
      done



      Then in shell prompt you can use:



      $ trash file1 file2





      share|improve this answer













      Use function instead of alias, defined in .bashrc



      nano ~/.bashrc 

      # put inside .bashrc:
      trash()
      for item in "$@" ; do
      echo "Trashing: $item"
      mv "$item" /home/$USER/.local/share/Trash/files
      done



      Then in shell prompt you can use:



      $ trash file1 file2






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Apr 21 at 10:11









      LeonidMewLeonidMew

      1,320624




      1,320624












      • thanks! This worked perfectly.

        – charsi
        Apr 21 at 10:16











      • Don't forget to close shell and open again to make this work

        – LeonidMew
        Apr 21 at 10:16











      • source ~/.bashrc works too

        – charsi
        Apr 21 at 10:17







      • 5





        You don't need a loop: trash() mv "$@" destination;

        – glenn jackman
        Apr 21 at 14:34

















      • thanks! This worked perfectly.

        – charsi
        Apr 21 at 10:16











      • Don't forget to close shell and open again to make this work

        – LeonidMew
        Apr 21 at 10:16











      • source ~/.bashrc works too

        – charsi
        Apr 21 at 10:17







      • 5





        You don't need a loop: trash() mv "$@" destination;

        – glenn jackman
        Apr 21 at 14:34
















      thanks! This worked perfectly.

      – charsi
      Apr 21 at 10:16





      thanks! This worked perfectly.

      – charsi
      Apr 21 at 10:16













      Don't forget to close shell and open again to make this work

      – LeonidMew
      Apr 21 at 10:16





      Don't forget to close shell and open again to make this work

      – LeonidMew
      Apr 21 at 10:16













      source ~/.bashrc works too

      – charsi
      Apr 21 at 10:17






      source ~/.bashrc works too

      – charsi
      Apr 21 at 10:17





      5




      5





      You don't need a loop: trash() mv "$@" destination;

      – glenn jackman
      Apr 21 at 14:34





      You don't need a loop: trash() mv "$@" destination;

      – glenn jackman
      Apr 21 at 14:34













      5














      You can only append arguments to an alias. Fortunately, mv allows you to do this, with the -t option



      alias trash='mv -t ~/.local/share/Trash/files'





      share|improve this answer



























        5














        You can only append arguments to an alias. Fortunately, mv allows you to do this, with the -t option



        alias trash='mv -t ~/.local/share/Trash/files'





        share|improve this answer

























          5












          5








          5







          You can only append arguments to an alias. Fortunately, mv allows you to do this, with the -t option



          alias trash='mv -t ~/.local/share/Trash/files'





          share|improve this answer













          You can only append arguments to an alias. Fortunately, mv allows you to do this, with the -t option



          alias trash='mv -t ~/.local/share/Trash/files'






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 21 at 14:32









          glenn jackmanglenn jackman

          12.9k2545




          12.9k2545





















              0














              You can also create a bash script and run that script with an alias.



              trash.sh:



              #!/bin/sh

              for arg in $*; do
              mv $arg /home/$USER/.local/share/Trash/files
              done

              exit 0


              .bashrc:



              alias trash="/path/to/script/trash.sh"





              share|improve this answer



























                0














                You can also create a bash script and run that script with an alias.



                trash.sh:



                #!/bin/sh

                for arg in $*; do
                mv $arg /home/$USER/.local/share/Trash/files
                done

                exit 0


                .bashrc:



                alias trash="/path/to/script/trash.sh"





                share|improve this answer

























                  0












                  0








                  0







                  You can also create a bash script and run that script with an alias.



                  trash.sh:



                  #!/bin/sh

                  for arg in $*; do
                  mv $arg /home/$USER/.local/share/Trash/files
                  done

                  exit 0


                  .bashrc:



                  alias trash="/path/to/script/trash.sh"





                  share|improve this answer













                  You can also create a bash script and run that script with an alias.



                  trash.sh:



                  #!/bin/sh

                  for arg in $*; do
                  mv $arg /home/$USER/.local/share/Trash/files
                  done

                  exit 0


                  .bashrc:



                  alias trash="/path/to/script/trash.sh"






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered yesterday









                  CPHCPH

                  843




                  843



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Ask Ubuntu!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1135728%2fbashrc-alias-for-a-command-with-fixed-second-parameter%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

                      Magento2 - How to hide price filter only in specific categories?Multiselect price filter attribute in layered navigationhide only some categories from layered navigation in magentoRemove Price Filter on certain categoriescustomize layered price filter?Hide Price for a particular customer groupPrice filter in layered navigation not working correctly with price including tax in magento 2.2.3Magento 2 how to hide attribute at Layered navigation?Magento 2. how to hide price only for specific categoriesMagento 2 How can I hide the price and total from cart and checkout summary?Magento2: Can we add navigation layered filter like price filter for other attribute?