How do I execute multiple commands using the same argument?

HoCo_

I wonder if it is possible to make chain actions in Ubuntu terminal like:

action 1 on objectA . then action 2 on objectA 

without having to repeat the name of objectA anymore.

Example:

touch file.js && openEditor "$1" 

or something like that.

steeldriver

With bash History Expansion, you can refer to the nth word of the current command line using !#:n e.g.

$ touch foobar && ls -l !#:1
touch foobar && ls -l foobar
-rw-rw---- 1 steeldriver steeldriver 0 Jun 20 14:54 foobar

$ touch foo bar && ls -l !#:2
touch foo bar && ls -l bar
-rw-rw-r-- 1 steeldriver steeldriver 12 Jun 20 14:58 bar

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I execute multiple commands when using find?

From Dev

How do i execute multiple commands sequentially on the command line?

From Dev

xargs : using same argument in multiple commands

From Dev

How do I open cmd with multiple startup parameters (I mean execute two commands when startup)?

From Dev

execute multiple commands in Linux using python in the same time

From Dev

How do I implement multiple argument generation using FsCheck?

From Dev

How can I get Ansible to execute multiple commands using with_items?

From Dev

How can I get Ansible to execute multiple commands using with_items?

From Dev

Docker execute multiple commands by passing CMD argument

From Dev

How do I execute a python script from the command line using custom commands?

From Dev

How do I properly invoke MSYS2 Bash commands using CMake execute_process()?

From Dev

How do I execute a python script from the command line using custom commands?

From Dev

How do I perform the same set of commands within multiple subdirectories, in a numerical order?

From Dev

How do I run multiple dotnet commands?

From Dev

How can i execute multiple commands with JAVA code?

From Dev

How can I execute multiple find commands in a single line?

From Dev

How do I insert the same line into multiple files using VIM

From Java

Using Docker-Compose, how to execute multiple commands

From Dev

How to execute multiple commands in system() , also using a variable

From Dev

How do I execute same webjob method multiple time only on one trigger message?

From Dev

How do I run execute commands from a file?

From Dev

How do I execute shell commands through eggPlant on Windows?

From Dev

How do I run execute commands from a file?

From Dev

How do I execute FTP commands on one line?

From Dev

How do I update a file using commands run against the same file?

From Dev

How do I update a file using commands run against the same file?

From Dev

How do you run Multiple XMLA Alter Commands at the same time?

From Dev

Read deadlock when using pipes to execute multiple shell commands on the same process

From Dev

Can I execute multiple lines sudo commands?

Related Related

  1. 1

    How do I execute multiple commands when using find?

  2. 2

    How do i execute multiple commands sequentially on the command line?

  3. 3

    xargs : using same argument in multiple commands

  4. 4

    How do I open cmd with multiple startup parameters (I mean execute two commands when startup)?

  5. 5

    execute multiple commands in Linux using python in the same time

  6. 6

    How do I implement multiple argument generation using FsCheck?

  7. 7

    How can I get Ansible to execute multiple commands using with_items?

  8. 8

    How can I get Ansible to execute multiple commands using with_items?

  9. 9

    Docker execute multiple commands by passing CMD argument

  10. 10

    How do I execute a python script from the command line using custom commands?

  11. 11

    How do I properly invoke MSYS2 Bash commands using CMake execute_process()?

  12. 12

    How do I execute a python script from the command line using custom commands?

  13. 13

    How do I perform the same set of commands within multiple subdirectories, in a numerical order?

  14. 14

    How do I run multiple dotnet commands?

  15. 15

    How can i execute multiple commands with JAVA code?

  16. 16

    How can I execute multiple find commands in a single line?

  17. 17

    How do I insert the same line into multiple files using VIM

  18. 18

    Using Docker-Compose, how to execute multiple commands

  19. 19

    How to execute multiple commands in system() , also using a variable

  20. 20

    How do I execute same webjob method multiple time only on one trigger message?

  21. 21

    How do I run execute commands from a file?

  22. 22

    How do I execute shell commands through eggPlant on Windows?

  23. 23

    How do I run execute commands from a file?

  24. 24

    How do I execute FTP commands on one line?

  25. 25

    How do I update a file using commands run against the same file?

  26. 26

    How do I update a file using commands run against the same file?

  27. 27

    How do you run Multiple XMLA Alter Commands at the same time?

  28. 28

    Read deadlock when using pipes to execute multiple shell commands on the same process

  29. 29

    Can I execute multiple lines sudo commands?

HotTag

Archive