[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Using aliases or functions in bash script



T o n g(mlist4suntong@yahoo.com) is reported to have said:
> Hi, 
> 
> A (adv) bash alias expansion question -- 
> How can I use my aliases or functions in my bash script?
> 
> I have the following alias and function defined in my ~/.bashrc:
> 
>   $ alias rd
>   alias rd='rmdir'
> 
>   $ type dt
>   dt is a function
>   dt () 
>   { 
>       pushd +$1
>   }
> 
> How can I use them in my script?

Sorry, I thought you and already worked theis out.  Here is an example
I threw together.  YMMV

********** -----------------------
#!/bin/sh

# Test calling a function in .bashrc

#  The function
#   make (create) an gzip archive
#   tarc() { tar czvf $1.tar.gz $1; }


# let this script know what the functions/aliases are
source .bashrc

#test tarc function
echo "Name of file to gzip: "
read file

tarc $file


#  Test of an alias in .bashrc
#
# the alias
#  alias show="apt-cache show $1"

# Test show alias
echo "Search Debian for filename: "
read name

show $name
********** -----------------------

HTH

Wayne

-- 
You know you've been spending too much time on the computer when your
friend misdates a check, and you suggest adding a "++" to fix it.
_______________________________________________________


Reply to: