I am looking for a way to register an alias in a shell script that is intended for temporary use.Why do I want this
A project involving multiple people, in a project file
It is assumed that there are many opportunities to issue a specific command.
For example... (Here, ex-command is used as an example)
When using it yourself
alias ex-command='It is enough if you register
When asking for confirmation work, you can't say "type ex-command."
However, I was wondering if the processing contents specific to the project should be registered in .bashrc...
From the above circumstances, if you have a "shell script that temporarily registers ex-command because it is only necessary for confirmation work",
When you use ex-command, you will be told "Please execute ex-command after executing this script".
I thought it would be easier to make a request.
GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)
I created and confirmed the following code.
#!/bin/bash alias ex-command='echo hello!'
Type in when you temporarily register
alias ex-command='echo hello!'To
It will be the one you typed in the shell script as it is.
Since my environment was bash, shebang is /bin/bash.
I ran chmod +x on the resulting file and ran it.
The alias was not registered even if I typed ex-command.
- You can temporarily register alias by typing command
- To register the alias permanently, describe it in .bashrc (for bash)
- To run alias with a shell script,
shopt -s expand_aliasesNeed to be set.
Regarding ↑, I feel a little different because it is "when I want to use it in a shell script".
Thank you for watching till the end.
If necessary information is missing, we will add it at any time, so thank you.
Answer # 1
Hmm... I was waiting because I thought I could get an answer soon...
I use the source command like this.
- bash - i can no longer switch users with the su command
- linux - is there a way to refer back to a character string that matched a wildcard in bash, etc?
- One command lets you understand the common parameters of the read command in the shell
- bash - xserver (x server) command cannot be used
- how to resolve phpmd command error in bash
- bash - unable to execute binary file ubuntu18043
- i want to browse two lists using shell (linux command) and extract specific lines that match
- Detailed method of passing password to ssh/scp command in bash script
- linux - retry process in for statement