Tuesday, October 25, 2022

[SOLVED] Use alias and add variable together

Issue

I found nice command to check whether in terminal:

curl wttr.in/

By adding after slash city name it will show whether in typed place for example:

curl wttr.in/NewYork

There is need to simplify this command using alias but then it appear a problem with variable after alias.

alias yyy="curl wttr.in/"

There is error trying to use alias with variable in terminal:

yyy NewYork 

How manage to use alias with variable?


Solution

You can create a function and use it the same way you use an alias

function yyy() { curl wttr.in/${1}; }

yyy NewYork


Answered By - MrBens
Answer Checked By - Mary Flores (WPSolving Volunteer)