setting up profile in unix

8 views
Skip to first unread message

gtuohy...@gtempaccount.com

unread,
Apr 21, 2015, 12:11:02 PM4/21/15
to unix-and-perl-...@googlegroups.com
I have set up a .bash_profile file in my home directory containing aliases, welcome message etc.  Aliases work fine, welcome message works fine but MYDATE shell is not being picked up, leaving the welcome message with only The current time is date "+%H:%M:%S %m/%d/%y". Any ideas?

Keith Bradnam

unread,
Apr 21, 2015, 12:11:44 PM4/21/15
to unix-and-perl-...@googlegroups.com


On Tuesday, April 21, 2015 at 9:11:02 AM UTC-7, gtuohy...@gtempaccount.com wrote:
I have set up a .bash_profile file in my home directory containing aliases, welcome message etc.  Aliases work fine, welcome message works fine but MYDATE shell is not being picked up, leaving the welcome message with only The current time is date "+%H:%M:%S %m/%d/%y". Any ideas?

Maybe you can include the relevant section of your .bash_profile file? 

gtuohy...@gtempaccount.com

unread,
Apr 21, 2015, 12:20:04 PM4/21/15
to unix-and-perl-...@googlegroups.com
Thanks Keith, the script is in nano as follows:

#ALIASES
alias ls='ls -p -l -S'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

#FIRST STEPS

MYDATE='date "+%H:%M:%S %m/%d/%y"'
echo "Good morning, welcome to Unix! The current time is $MYDATE"

#ENVIRONMENT VARIABLES
#(blank for now)

Keith Bradnam

unread,
Apr 21, 2015, 1:13:42 PM4/21/15
to unix-and-perl-...@googlegroups.com
Remember, you can always test these things directly in the terminal. I.e. 

# Your original code
MYDATE='date "+%H:%M:%S %m/%d/%y"'
echo $MYDATE

date "+%H:%M:%S %m/%d/%y"


The problem is that you are capturing the date function inside single quotes making the whole thing just a text string. If you want to capture output from Unix commands you need to use backticks (`) not apostrophe characters:

MYDATE=`date "+%H:%M:%S %m/%d/%y"`
echo $MYDATE

10:11:30 04/21/15

gtuohy...@gtempaccount.com

unread,
Apr 21, 2015, 1:25:29 PM4/21/15
to unix-and-perl-...@googlegroups.com
Perfect! All working now.

Many thanks for your prompt replies!

Best wishes, Gearoid


On Tuesday, 21 April 2015 17:11:02 UTC+1, gtuohy...@gtempaccount.com wrote:
Reply all
Reply to author
Forward
0 new messages