Find the answer to your Linux question:
Results 1 to 4 of 4
So when you type history in bash you get a list of your history...however I'm trying to get the same output into my bash script but its not working. I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2006
    Posts
    8

    displaying history in a script


    So when you type history in bash you get a list of your history...however I'm trying to get the same output into my bash script but its not working. I do
    Code:
    #!/bin/bash
    
    history
    and nothing outputs, I've tried a few things such as

    Code:
    echo history, or echo $history
    but still no luck, any ideas?
    Thank you,

  2. #2
    Administrator jayd512's Avatar
    Join Date
    Feb 2008
    Location
    Kentucky
    Posts
    5,023
    Try this:
    Code:
    #!/bin/bash
    
    cat .bash_history
    Jay

    New users, read this first.
    New Member FAQ
    Registered Linux User #463940
    I do not respond to private messages asking for Linux help. Please keep it on the public boards.

  3. #3
    Just Joined!
    Join Date
    May 2006
    Posts
    8
    Sorry I made a mistake, I need to find the current history number. I tried
    history ! 0
    but it still says that I need to specify a numeric number. Any ideas?

    Thank you

  4. $spacer_open
    $spacer_close
  5. #4
    Administrator jayd512's Avatar
    Join Date
    Feb 2008
    Location
    Kentucky
    Posts
    5,023
    What exactly do you mean by 'current history number'?
    Jay

    New users, read this first.
    New Member FAQ
    Registered Linux User #463940
    I do not respond to private messages asking for Linux help. Please keep it on the public boards.

Posting Permissions

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