Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: save variables and aliases

  1. #1
    Join Date
    Dec 2008
    Location
    Montevideo, Uruguay
    Posts
    451

    Wink save variables and aliases

    Hi,

    Here is the issue:

    I create saome variables to makea shotcut to some directories I go frequently (so, I then I type, e.g. cd $P_DIR). Of Course before that I put a valid value into P_DIR variabe.

    Also, alias, as

    alias cls=clear

    So, I type cls, and is the same as the commando clear (but shorter)


    What I want to do is that those variables as aliases stay in the computer when I reboot or turn off and turn on.

    So, I put "somewhere" (this is the place(s) maybe one for variables, and other for aliases, turn of the computer, and when I turn on, the aliases and variables are still there.

    thanks for any feedback,

    agunet74
    agunet74

  2. #2
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: save variables and aliases

    Even better still, you use a text editor to enter those alias commands and variable assignments into a file that is read by bash when it is started up and they will be available when you run bash. One such file is .alias in your home directory (note the . in front). For example you put lines like:

    Code:
    alias h=history
    export CVS_RSH=ssh
    and so forth in it and next time you login or start a bash shell, they will be available.

    PS: ~/.alias is not a file that's documented as read by bash if you are wondering, but the default .bashrc (which is normally read by bash) on openSUSE has this line at the end:

    Code:
    test -s ~/.alias && . ~/.alias

  3. #3
    Join Date
    Dec 2008
    Location
    Montevideo, Uruguay
    Posts
    451

    Default Re: save variables and aliases

    It didn't work.

    That sentences din't save me any variable or alias.

    Any other suggestion ?
    agunet74

  4. #4
    Join Date
    Nov 2009
    Location
    West Virginia Sector 13
    Posts
    15,650

    Default Re: save variables and aliases

    Put them in .bashrc directly

  5. #5
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: save variables and aliases

    Quote Originally Posted by agunet74 View Post
    It didn't work.

    That sentences din't save me any variable or alias.

    Any other suggestion ?
    What exactly did you do? Do you understand that you can't "save" your current settings, but you write them down so that they are read in by each shell? So you have to put all the assignments you made into that file. Any new ones you make during a session are not "saved".

  6. #6
    Join Date
    Dec 2008
    Location
    Montevideo, Uruguay
    Posts
    451

    Default Re: save variables and aliases

    alias put them on .bashrc works fine!

    Now .. I want to set a value to vriable and when reboot my system still have that value.

    I know, maybe there is a file or something. I''ve done it before on unix AIX and unix HP.

    This has to be the same. How can I save values to variables ? When I say "save" can be "write on a file".

    thanks

    agunet74
    agunet74

  7. #7
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: save variables and aliases

    You would have to dump the variable assignments to a file and then arrange to read them in again later. This is a scripting problem. There are no ready made commands for this because usually people put what they want to be "permanent" in .bashrc or .aliases and don't want to carry over the assignments from a previous session. But the tools are there to do this.

  8. #8
    Join Date
    Dec 2008
    Location
    Montevideo, Uruguay
    Posts
    451

    Default Re: save variables and aliases

    But the tools are there to do this.
    What tools are you talking about Flux ?
    agunet74

  9. #9
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: save variables and aliases

    No, shell scripts.

  10. #10
    Join Date
    Dec 2008
    Location
    Montevideo, Uruguay
    Posts
    451

    Default Re: save variables and aliases

    When I meant flux, I meant ken_yap. I thought flux was his nick!

    Back to the issue:

    I don't understand or I understand less than the beginning of this forum.

    Is there a script that storage variables ? If so, whi is it ? In which directory can be found?

    If not.. How can I make one and which name shold I save it ?

    (sorry if my english is not very good)

    thanks again KEN!!
    agunet74

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •