0

I am trying to alias a command with an option. Basically, I have a command my_tool -version which returns:

TOOL : my_tool v1.2.3.4

In a new version of the tool, my_tool is a link to my_tool_1, and my_tool -version returns:

TOOL : my_tool_1 v1.2.3.5

For backward compatibility reasons this is awful, and I would like to have an alias on the global command my_tool -version which would achieve :

my_tool_1 -version | sed 's/my_tool_1/my_tool/'

I tried to alias the command my_tool -version, but it does not want to handle the second argument. Would anyone have any idea on how to achieve this ?

SLePort
  • 15,211
  • 3
  • 34
  • 44

1 Answers1

-1

try this;

echo "$(my_tool_1 -version 2>&1)" | sed 's/my_tool_1/my_tool/'

"2>&1" simply points everything sent to stderr, to stdout instead.

Mustafa DOGRU
  • 3,994
  • 1
  • 16
  • 24
  • Although this code may help to solve the problem, it doesn't explain _why_ and/or _how_ it answers the question. Providing this additional context would significantly improve its long-term educational value. Please [edit] your answer to add explanation, including what limitations and assumptions apply. – Toby Speight Oct 03 '16 at 16:12