Skip to main content

All Questions

1 vote
2 answers
239 views

bash, pass an argument to the 'history' command

I do the following to make history more sensible (i.e. seeing when a command is run can be fairly critical when troubleshooting) shopt -s histappend; # Append commands to the bash history (~/....
YorSubs's user avatar
  • 651
0 votes
1 answer
176 views

Access last command of history within a function [duplicate]

I'm trying to create a function that will echo the previous to last command from the current terminal. This is the expected output (here I call the desired function f): $ history 1 history 1 $ f ...
builder-7000's user avatar
1 vote
2 answers
68 views

How to improve function for simplifying history command

I came up with this snippet to simplify use of history and prevent flooding of the scroll buffer: h() { if [ $# -eq 1 ]; then history | grep $1 | tail -n $(expr $(tput lines) - 1) ...
forthrin's user avatar
  • 2,449
0 votes
2 answers
125 views

Why must you be careful when using Bash's built in command history function to re-run previous commands that contain variables?

I know !! re-runs commands but what exactly would occur if I re-ran a command that had a variable in the command?
linux8807's user avatar
  • 205
3 votes
2 answers
348 views

How to show last command with expanding function in bash

I'm using function like this. $ find-grep () { find . -type f -name "$1" -print0 | xargs -0 grep "$2" ; } After I type: $ find-grep *.c foo I want to get expanded last command string. In this case: ...
ironsand's user avatar
  • 5,425