K
K
ksvdon2014-05-19 13:35:55
linux
ksvdon, 2014-05-19 13:35:55

Working with alias via script

Never faced such a problem before. I just write alias in the console and get information about alias(s). If I run it through a script (i.e. I just write alias in a text document and run it for execution), it doesn't show anything. There are no problems with other commands, but alias does not want to work through the script in any way. Tell me how to be ... (It is necessary to check in the script whether there is an alias for one command. If there is, cancel it, and apply it back at the end of the script. I already wrote everything. But it turned out that he didn’t want to work out the alias in any way .... ) What are the features?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor, 2014-05-19
@ksvdon

In bash, you can
run it through bash -i and write shopt -s expand_aliases . Then you don't have to do it . $HOME/.bashrc .
That is, in the script it will look like this:

#!/bin/bash -i
shopt -s expand_aliases
alias

S
sonik_spb, 2014-05-19
@sonik_spb

alias for each user like his own. The script can works not from the necessary user?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question