0

I have basically mounted a disk image and am required to analyse it by printing various bits of information to the terminal via a bash script.

I understand you can print your bash history by typing 'history' into the command line and hitting enter.

I need the result to be the same, however;

  1. it needs to be executed within a bash script
  2. it needs to be the bash history for the disk image, not my computer

Big thanks for all that help

4
  • 1
    You can look at .bash_history in the user's home dir in the disk image Apr 3, 2017 at 17:57
  • Thanks for your reply, I am unable to locate the .bash_history folder on the disk image file. Is there a command I can do to find it? Thanks Apr 3, 2017 at 18:00
  • 1
    Since it starts with a ., it's hidden by default. You can show hidden files with ls -a or search for it with find /yourpath -name '.bash_history' Apr 3, 2017 at 18:03
  • See my answer, did it work?
    – Montmons
    Apr 10, 2017 at 16:16

1 Answer 1

0

Ok, so basically you do this:

  1. Make sure the disk image is mounted
  2. Open up a terminal
  3. Change directory into the disk image using cd /path/to/your/disk_image
  4. Find the file that houses the BASH history (biggest chance it is a hidden file so list them all via find /path/to/your/disk_image -type f -iname ".*" -ls.
  5. You could (if you want) append its contents to the current in-memory history list via history -r /path/to/your/disk_image/.bash_history
  6. Create a BASH script and simply put VAR1=$(cat /path/to/your/disk_image/.bash_history) to save the contents of the file to your script so you can use it from within the BASH script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.