0

I have a command like python abc.py -p 'File Path' -c 'File path'.

1 Answers1

3

I assume what you wanted to ask is how to use command line arguments in conjunction with an alias (which you cannot). Try to define a function instead:

  • Using zsh:

    % func abc() { echo python abc.py -p "$1" -c "$2" }
    % abc def ghi
    python abc.py -p def -c ghi
    
  • Using bash:

    $ function abc { echo python abc.py -p "$1" -c "$2"; }
    $ abc def ghi
    python abc.py -p def -c ghi
    

    You might also want to have a look at alias vs. function in bash scripts.

  • 1
    Very good suggestion, but is this valid bash code? Can the new user understand this example for solving the question? – vanadium Apr 03 '21 at 07:51
  • @vanadium OP didn't mention which shell s/he uses (and the provided reference should explain further details), but fair enough; I added a Bash-conformant example. – Markus Ueberall Apr 03 '21 at 10:37
  • Excellent. Bash is the default in the Ubuntu desktop, but it is excellent, of course, also to show how it works for other shells. – vanadium Apr 03 '21 at 11:01
  • 2
    ... or portably, abc () { echo python abc.py -p "$1" -c "$2"; } – steeldriver Apr 03 '21 at 12:24