How To
Summary
The fc command only reports the history for my user. How can I parse another .sh_history file?
Steps
# cat /tmp/myscript.pl
#!/usr/bin/perl
use POSIX qw(strftime); my $filename = shift @ARGV;
open(my $fh, "<", $filename) or die "Failed to open file: $filename - $!"; while (my $string = <$fh>) {
chomp $string; my ($timestamp) = $string =~ /#(\d+)#/;
if ($timestamp) { my $formatted_time = strftime("%Y-%m-%d %H:%M:%S", localtime($timestamp)); print "Line: $string\n"; print "Timestamp (Epoch): $timestamp\n"; print "Timestamp (Formatted): $formatted_time\n"; } } close($fh);
|
# /tmp/myscript.pl /.sh_history Line: lslpp -l #▒#1686075298#▒# Timestamp (Epoch): 1686075298 Timestamp (Formatted): 2023-06-06 19:14:58 Line: ps -ef #▒#1686075301#▒# Timestamp (Epoch): 1686075301 Timestamp (Formatted): 2023-06-06 19:15:01 Line: /tmp/p1 /.sh_history #▒#1686075307#▒# Timestamp (Epoch): 1686075307 Timestamp (Formatted): 2023-06-06 19:15:07 Line: mv /tmp/p1 /tmp/myscript.pl #▒#1686075329#▒# Timestamp (Epoch): 1686075329 Timestamp (Formatted): 2023-06-06 19:15:29 Line: /tmp/myscript.pl /.sh_history #▒#1686075338#▒# Timestamp (Epoch): 1686075338 Timestamp (Formatted): 2023-06-06 19:15:38 |
Additional Information
SUPPORT |
---|
If you require more assistance, use the following step-by-step instructions to contact IBM to open a case for software with an active and valid support contract. 1. Document (or collect screen captures of) all symptoms, errors, and messages related to your issue. 2. Capture any logs or data relevant to the situation. 3. Contact IBM to open a case: -For electronic support, see the IBM Support Community: 4. Provide a clear, concise description of the issue. - For more information, see: Working with IBM AIX Support: Describing the problem. 5. If the system is accessible, collect a system snap, and upload all of the details and data for your case. - For more information, see: Working with IBM AIX Support: Collecting snap data |
Related Information
Was this topic helpful?
Document Information
More support for:
AIX
Component:
Commands
Software version:
All Versions
Operating system(s):
AIX
Document number:
7001741
Modified date:
06 June 2023
UID
ibm17001741