Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-06-2010, 09:16 PM   #1
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 181

Rep: Reputation: 17
set alias in bash scripts

I tried this to set an alias:

alias lsf='ls -f'

and it works fine... But when I put it in a bash script it doesnt work.


cd ~
alias lsf='ls -F'

I get the following output:
line 3: lsf: command not found

Any ideas?
Old 09-06-2010, 10:07 PM   #2
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
From manpage of alias:
An alias definition shall affect the current shell execution environment and the execution environments
of the subshells of the current shell. When used as specified by this volume of IEEE Std 1003.1-2001, the
alias definition shall not affect the parent process of the current shell nor any utility environment
invoked by the shell; see Shell Execution Environment .
Old 09-06-2010, 10:13 PM   #3
Registered: Aug 2004
Location: Philadelphia,PA
Posts: 181

Original Poster
Rep: Reputation: 17
Originally Posted by quanta View Post
Thanks for that, after some searching I did it like this:

alias lsf='ls -F'
shopt -s expand_aliases

Which seemed to work for what I needed.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Where to set global alias? exitsfunnel Linux - General 9 07-29-2014 10:12 AM
[SOLVED] How to set permanent alias konzo Linux - Newbie 1 01-23-2010 11:03 AM
[SOLVED] Finding bugs in bash scripts, Analyis tool for bash traene Programming 2 10-31-2009 12:42 PM
How to set alias? thomas2004ch Linux - Newbie 5 08-05-2009 08:02 AM
How to set an IP alias in Kubuntu leupi Ubuntu 1 04-14-2006 12:26 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:44 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration