Sunday, March 24, 2013

Bash Tips: Call aliases from shell your script

Use 'shopt -s expand_aliases' from your script to expand aliases:

$ cat aliases.sh 
#!/bin/bash

alias ll='ls -lFh'
type ll


$ ./aliases.sh
./aliases.sh: line 5: type: ll: not found


$ cat aliases.sh 
#!/bin/bash

shopt -s expand_aliases
alias ll='ls -lFh'
type ll


$ ./aliases.sh 
ll is aliased to `ls -lFh'

No comments: