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

Thread: Quick help with history cmd in bash

  1. #1
    Join Date
    Oct 2009
    Location
    127.0.0.1
    Beans
    142
    Distro
    Ubuntu 10.04 Lucid Lynx

    Quick help with history cmd in bash

    When I type history at the prompt I should be getting a list of all the commands that i used but instead i'm getting this message:

    Code:
    skynet@skynet-desktop~ $ history
    bash: $1: unbound variable
    Can anyone tell me why and how i can fix this?
    sudo --JK

  2. #2
    Join Date
    Oct 2009
    Location
    127.0.0.1
    Beans
    142
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Quick help with history cmd in bash

    bump
    sudo --JK

  3. #3
    Join Date
    Sep 2010
    Location
    Indian Capital City
    Beans
    916
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Quick help with history cmd in bash

    Though I am not sure, but can you try this:
    Code:
    echo $anything
    When you have eliminated the impossible, whatever remains, however improbable, must be the truth !!
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Mark it [SOLVED] if the issue has been resolved

  4. #4
    Join Date
    Oct 2009
    Location
    127.0.0.1
    Beans
    142
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Quick help with history cmd in bash

    Thanks for your reply but that didn't solve the problem for me.

    Code:
    skynet@skynet-desktop~/Documents $ echo $anything
    bash: anything: unbound variable
    sudo --JK

  5. #5
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,790
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Quick help with history cmd in bash

    The command:
    Code:
    $ set -u
    produces a similar behavior. You can reset it like this:
    Code:
    $ set +u
    However, if it happens always you open a terminal, it means it is set in some of the bash files. Have you mod any of these files?
    /etc/profile
    /etc/bash.bashrc
    /etc/bash.bash.logout
    ~/.bash_profile
    ~/.bashrc
    ~/.bash_logout
    ~/.inputrc
    Last edited by papibe; October 11th, 2010 at 06:16 AM.

  6. #6
    Join Date
    Sep 2010
    Location
    Indian Capital City
    Beans
    916
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Quick help with history cmd in bash

    Quote Originally Posted by juil View Post
    Thanks for your reply but that didn't solve the problem for me.

    Code:
    skynet@skynet-desktop~/Documents $ echo $anything
    bash: anything: unbound variable
    That won't change anything. Actually I was just checking whether your shell is behaving like "set -u" or not. Looks like it is

    Did you try what papibe said ? I am not able to reproduce your error if I set 'set -u' in my active shell so can't say if papibe's solution will help or not
    Last edited by luvshines; October 11th, 2010 at 06:27 AM. Reason: Added info
    When you have eliminated the impossible, whatever remains, however improbable, must be the truth !!
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Mark it [SOLVED] if the issue has been resolved

  7. #7
    Join Date
    Oct 2009
    Location
    127.0.0.1
    Beans
    142
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Quick help with history cmd in bash

    Thanks for your reply!
    I executed the set +u command but it's not behaving like it should.
    Instead it's giving me a list of what the most recent activities are.
    And YES, maybe a month ago I downloaded a Terminal theme, copied and pasted over the existing .bashrc texts. I have it saved somewhere else. Should I have copied it below the exisitng .bashrc text?

    So here is what I get when i type history:


    Code:
    2010-10-11 03:12:00 status half-configured avant-window-navigator-data-trunk 0.4.1~bzr743+201009122042~lucid1
    2010-10-11 03:12:00 status installed avant-window-navigator-data-trunk 0.4.1~bzr743+201009122042~lucid1
    2010-10-11 03:12:00 configure avant-window-navigator-trunk 0.4.1~bzr743+201009122042~lucid1 0.4.1~bzr743+201009122042~lucid1
    2010-10-11 03:12:00 status unpacked avant-window-navigator-trunk 0.4.1~bzr743+201009122042~lucid1
    2010-10-11 03:12:00 status half-configured avant-window-navigator-trunk 0.4.1~bzr743+201009122042~lucid1
    2010-10-11 03:12:00 status installed avant-window-navigator-trunk 0.4.1~bzr743+201009122042~lucid1
    2010-10-11 03:12:00 status triggers-pending libc-bin 2.11.1-0ubuntu7.2
    2010-10-11 03:12:01 configure awn-applets-c-core-trunk 0.4.1~bzr1435-1.10.04 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:01 status unpacked awn-applets-c-core-trunk 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:01 status half-configured awn-applets-c-core-trunk 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:01 status installed awn-applets-c-core-trunk 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:01 configure awn-applets-c-extras-trunk 0.4.1~bzr1435-1.10.04 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:01 status unpacked awn-applets-c-extras-trunk 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:01 status half-configured awn-applets-c-extras-trunk 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:01 status installed awn-applets-c-extras-trunk 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:01 configure awn-applets-python-core-trunk 0.4.1~bzr1435-1.10.04 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:01 status unpacked awn-applets-python-core-trunk 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:02 status half-configured awn-applets-python-core-trunk 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:02 status installed awn-applets-python-core-trunk 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:02 configure awn-applets-python-extras-trunk 0.4.1~bzr1435-1.10.04 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:02 status unpacked awn-applets-python-extras-trunk 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:02 status half-configured awn-applets-python-extras-trunk 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:02 status installed awn-applets-python-extras-trunk 0.4.1~bzr1435-1.10.04
    2010-10-11 03:12:02 configure awn-settings-trunk 0.4.1~bzr743+201009122042~lucid1 0.4.1~bzr743+201009122042~lucid1
    2010-10-11 03:12:02 status unpacked awn-settings-trunk 0.4.1~bzr743+201009122042~lucid1
    2010-10-11 03:12:02 status half-configured awn-settings-trunk 0.4.1~bzr743+201009122042~lucid1
    2010-10-11 03:12:02 status installed awn-settings-trunk 0.4.1~bzr743+201009122042~lucid1
    2010-10-11 03:12:03 trigproc libc-bin 2.11.1-0ubuntu7.2 2.11.1-0ubuntu7.2
    2010-10-11 03:12:03 status half-configured libc-bin 2.11.1-0ubuntu7.2
    2010-10-11 03:12:03 status installed libc-bin 2.11.1-0ubuntu7.2
    sudo --JK

  8. #8
    Join Date
    Sep 2010
    Location
    Indian Capital City
    Beans
    916
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Quick help with history cmd in bash

    Atleast it gives something now

    For future, first backup the working files and then try nething new

    For now, just check if history command has not be aliased:
    Code:
    alias | grep -i history
    Also, check the following:
    Code:
    set | grep "^HIST"
    If you find something like HISTFILE, open the specified file and see if history is actually there or not(No need to paste it here)
    Last edited by luvshines; October 11th, 2010 at 04:44 PM. Reason: Added info
    When you have eliminated the impossible, whatever remains, however improbable, must be the truth !!
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Mark it [SOLVED] if the issue has been resolved

  9. #9
    Join Date
    Oct 2009
    Location
    127.0.0.1
    Beans
    142
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Quick help with history cmd in bash

    Much appreciated!
    The HISTFILE which is .bash_history DOES show all the list of commands I executed so it's saving it, and that's good.

    As for the aliasing when i typed 'alias | grep -i history', it shows this:

    Code:
    skynet@skynet-desktop~/Documents/Test $ alias | grep -i history
    alias alert_helper='history|tail -n1|sed -e "s/^\s*[0-9]\+\s*//" -e "s/;\s*alert$//"'
    alias h='history | grep $1'
    alias hgrep='history | grep --color=always'
    alias history='apt-history'
    alias historyi='apt-history install'
    alias historyre='apt-history remove'
    alias historyro='apt-history rollback'
    alias historyu='apt-history upgrade'
    alias top-commands='history | awk "{print $2}" | awk "BEGIN {FS="|"} {print $1}" |sort|uniq -c | sort -rn | head -10'
    So, this is from the .bashrc theme that i said i pasted about a month ago. I'm going to guess at this but should it be:

    Code:
    alias history='history'
    I don't even know why the theme creator even aliased history...
    Also I did have the default .bashrc saved as .bashrc-backup, so i can retrieve it anytime.
    Last edited by juil; October 11th, 2010 at 05:35 PM.
    sudo --JK

  10. #10
    Join Date
    Sep 2010
    Location
    Indian Capital City
    Beans
    916
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Quick help with history cmd in bash

    Quote Originally Posted by juil View Post
    Much appreciated!
    The HISTFILE which is .bash_history DOES show all the list of commands I executed so it's saving it, and that's good.

    So, this is from the .bashrc theme that i said i pasted about a month ago. I'm going to guess at this but should it be:

    Code:
    alias history='history'
    I don't even know why the theme creator even aliased history...
    Also I did have the default .bashrc saved as .bashrc-backup, so i can retrieve it anytime.
    Actually it should not be aliased at all. To run it unaliased temporarily, just do:
    Code:
    unalias history; history
    OR
    \history
    unalias keywork will last only for the session in which it was invoked. The '\' calling will be only for that single instance of call

    For a permanent solution, just see where the aliases have been defined for history, comment them out, save it and exit that shell. Then open a new one to see the changes.
    PS: Oh by the way, for the set +u thing, where did you make the change ??
    Last edited by luvshines; October 11th, 2010 at 08:03 PM. Reason: Improved beauty cosmetics
    When you have eliminated the impossible, whatever remains, however improbable, must be the truth !!
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Mark it [SOLVED] if the issue has been resolved

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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