定义
#!/bin/bashalias ll="ls -al"
执行
内部 alias
开启 expand_aliases
❯ cat 3.sh#!/bin/bashshopt -s expand_aliasesalias test7="ssh xx@xxxxx.com"test7❯ ./3.shLast login: Tue Nov 16 11:26:58 2021 from 192.168.88.101[bae@syt-dev7-d:~]$
外部 alias
方式一 source
❯ cat 3.sh#!/bin/bashshopt -s expand_aliasessource ~/.bashrctest7❯ ./3.shLast login: Tue Nov 16 11:26:58 2021 from 192.168.88.101[bae@syt-dev7-d:~]$
方式二 bash -i
❯ cat 3.sh#!/bin/bashshopt -s expand_aliasestest7❯ ./3.sh./3.sh: line 4: test7: command not found❯ bash -i ./3.shLast login: Tue Nov 16 11:26:46 2021 from 192.168.88.22[bae@syt-dev7-d:~]$
ssh command alias
ssh xx@xxx /bin/bash -ic ‘ll;lxgkp’
