P
P
pavelkunyavskiy2018-02-12 13:27:53
bash
pavelkunyavskiy, 2018-02-12 13:27:53

How to make an alias for a console string with a variable?

How to make an alias with a variable, for example I want to execute such a command sudo systemctl {{название}} start
And then call for example ctl mongodorctl nginx

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xotkot, 2018-02-12
@pavelkunyavskiy

sudo systemctl {{name}} start

didn't you mess up by chance?
maybe so ?
If yes, then it's easier than ever:
alias ctl="sudo systemctl start"

R
riot26, 2018-02-12
@riot26

Create a file in any directory from $PATH ( echo $PATH)

cd /usr/bin
touch ctl

put something like this in it:
#!/bin/bash
sudo systemctl $1 start

more about the parameters and keys
give execution rights:
chmod +x ctl

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question