4

I would like to know how to add something to the end of a specific bash command without having to type it out explicitly.

For example, I would like to be able to type:

$ mycommand argument

and the line will be submitted as:

$ mycommand argument &

I know how to set up an alias in my .bashrc (e.g. alias command="command -i") which will let me add non-positional arguments but I can't figure out how add something to the end.

4
  • You can can write a shell script, make it executable chmod +x filename and place it into one of the directories in the execution path (echo $PATH). This is more related to system administration. Commented Dec 13, 2016 at 11:56
  • 1
    You can declare a function instead of an alias if you need more power. Commented Dec 13, 2016 at 12:00
  • Does this concerns one (or a few) specific commands, or every possible command? Commented Dec 13, 2016 at 12:09
  • A specific, pre-designated command. Updated question to be clearer. Commented Dec 13, 2016 at 12:12

1 Answer 1

5

Define a shell function.

mycommand () {
  command mycommand "$@" &
} 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, this works. The key for me was the use of the of the command command, otherwise it wasn't interpreting the '&' correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.