Jump to content

Alias - why is it not working? [solved]


Recommended Posts

I am going through some tutorials and one of them was to modify the .bash_profile in order to add some commands. I have entered the following one but it is not working any ideas why?:

 

alias today='date +"%A, %B %-d, %Y"'

 

It is supposed to give you the date with nice formatting.

Thanks

TheNovice

Link to comment
Share on other sites

Try it after rebooting. Changes to bashrc and bash_profile don't take effect until you reboot. There's a command you can run to make them take effect immediately but I don't recall what it is. Also, in mandriva, user specific aliases are normally put in bashrc IIRC. I think putting them in either file should work however.

Link to comment
Share on other sites

Guest silverback011

You can just issue this in the terminal that you are using:

 

alias today='date +"%A, %B %-d, %Y"'

 

Then when you issue the command 'today' it will work for that terminal. I just tried it on my machine and it works. This is a good way to test out your aliases before you commit to them. You do need root if you are doing this in the system wide configuration file.

 

To make it permanent you need to add it to your bash config file. Instead of rebooting. You can just:

 

source .bashrc

 

If you added it to your user bashrc file. That will read it for the current shell. In Konsole any newly opened terminals will read the new bashrc so you don't need to do that. But for any shells already opened you need to source it. Of course this all assuming you are using the bash shell

 

echo $SHELL

 

will tell you what terminal you are using. I hope this helps.

 

Any other questions just ask.

Link to comment
Share on other sites

Step1: type your alias command directly into the console. Does it give an error or is it ok?

Step2: type "today" into your console. Does it recognise your alias?

Step3: double check what you put in your bash profile with what just worked in the console. Are you sure the single and double quotes are the right way round?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...