recall commands previously typed in a shell or other utility

learn more… | top users | synonyms

2
votes
0answers
33 views

Why does “less” sometimes forget its history

I set and exported $LESSHISTFILE and $LESSHISTSIZE but if I perform a search in one less session, close, reopen it and try to repeat my last search I get "No previous regular expression (press ...
2
votes
1answer
17 views

How to cancel and keep reverse-i-search?

Often I fail to find something with reverse-i-search but want to keep what I have already written. For example, typing pdflatex fails to complete to pdflatex mydocument.tex. If I then cancel it with ...
1
vote
1answer
68 views

Using only in-memory command history

How can I prevent Bash from writing history entries to disk? My ~/.bashrccontains the line trap 'unset HISTFILE; exit' SIGHUP but it doesn't have the desired effect. If I run history -c && ...
1
vote
2answers
128 views

Write bash_history to a file with a timestamp

I need help with the script below. The requirement is to capture command line history in a file with specific date and time of commands, when they were executed. The below script captures history ...
1
vote
1answer
72 views

How to get last N commands from history?

I want to see what are the last N commands in my history. I thought history | tail -n 5 would make it, but I noticed that a multiline command counts for as many lines as it has. $ echo "hello how are ...
13
votes
1answer
203 views

Update bash history on others terminals on exit of one

I know this question has a similar interpretation, as its asked here keep updating (and duplicated here). But what I'm trying to achieve is a bit different. I don't like the idea of my prompt ...
1
vote
1answer
55 views

Detailed history of all commands/actions (also in GUI)

The famous history command shows us a list of recently executed commands. If we set the HISTTIMEFORMAT variable we can also see when the commands where executed. I would like a more general version of ...
1
vote
1answer
44 views

How to exclude command from history list, but to keep it in “live” history?

I've meanwhile managed to keep my history a lot cleaner thanks to you guys' great tips involving the HISTIGNORE option in .bashrc, omitting all those pointless ll or df -k lines. However, I've ...
1
vote
2answers
95 views

Bash - incremental history search (ctrl+r) - matching multiple non-adjacent words

When using Ctrl+R to search bash history, is there some way to match two words that aren't next to each other. For example, let's say I wanted to find the last command that contained httpd and awk ...
1
vote
1answer
67 views

Recover deleted commands from history?

If someone were to delete commands from the shells history, is there any way to recover those deleted commands in Linux?
2
votes
1answer
29 views

repeat bash history expansion substitution for all the matches

:& repeats bash history expansion substitution. For example: $ echo 1 1 1 1 1 1 1 1 1 1 $ ^1^9 echo 9 1 1 1 1 9 1 1 1 1 $ echo 1 1 1 1 1 1 1 1 1 1 $ ^1^9^:& echo 9 9 1 1 1 9 9 1 1 1 $ echo 1 ...
2
votes
1answer
64 views

Is it possible to track bash commands in real time?

I'd like to know if I can track commands entered by user in a bash shell, in real time. What I'm trying to do is something similar to thefuck, but I need to prompt the user as and when he enters new ...
2
votes
3answers
38 views

reuse the last command output at the given index/line-num

ls displays: entry1 entry2 entry3 How can I reuse the above output (not all of the entries but the entry at a given line, say n) in the next shell command? Something like: vi $(!!)@3 Must ...
1
vote
0answers
20 views

Cross-session duplicate removal in bash command history

The problem context: always active ignoreboth and erasedups HIST_SIZE and FILESIZE with desired/practical limits of different history lines for our user almost always have multiple parallel sessions ...
2
votes
5answers
162 views

Bash and its exclamation mark command, preview actual command before executing it?

! as a prefix to some string will execute whatever command in the command buffer that starts with the (partial) string given. There are also some other uses for it. See e.g. Understanding the ...
2
votes
1answer
137 views

move back to the end of bash history when using reverse search?

I keep fairly long bash history and sometimes when I search for something with bash reverse search function(Ctrl+r) I end up at the beginning of search history and I still did not find what I needed ...
0
votes
0answers
19 views

How can I copy the previous argument for the *current* command? [duplicate]

I can use Alt+. or !$ to get the last argument passed to the previous command, however, is it possible to get the last argument passed to the current command? For example, something that I do ...
7
votes
2answers
153 views

Keeping history per working directory (cf. per shell session)

Is there a way to make a modern shell's history feature be scoped to a path? My working contexts are split up as paths on the file system, and the pattern of shell activity, such as repeatedly issued ...
2
votes
1answer
169 views

How do I clear the terminal History?

I am using Linux Mint 17.1 Rebecca for about 2 days and accidentally typed my password into the terminal which is now displayed in the history list of commands I have previously typed. I want to ...
1
vote
0answers
61 views

Why can I change bash history?

Why does bash change the history even I'm not executing a command I'm modifying? For example, if I type: $ echo foo1 foo1 $ echo foo2 foo2 $ echo foo3 foo3 After this, I press up twice, and I get ...
0
votes
1answer
18 views

Getting the starting position in the history that will be appended to the history file (not read from the file or previously written)

I'm trying to write functions to remove some history lines using history -d before it is written to the file, while leaving them usable in the shell itself. But apparently this command will not ...
4
votes
1answer
55 views

Search history from multiple bash session only when Ctrl + R is used, not when arrow keys are used

I usually have multiple bash sessions open. I want the history from multiple session to appear when doing a search (with Ctrl + R). When arrow keys are used only the current bash session's history ...
1
vote
1answer
37 views

Is it possible to get working history for multi-line commands in mksh, using vi editing mode?

On my Debian systems, I have always used pdksh as my interactive shell. Originally, command-line history behavior was similar to what I grew up with on platforms like AIX and Solaris. Recently, ...
5
votes
3answers
112 views

How to undo changes in the commands-history?

In UNIX systems you can press top and bottom arrows to navigate through the previous commands. This is extremely handy. Sometimes, I go up and find a command that I want to use again, but with some ...
2
votes
1answer
73 views

Execute commands from history that match regex or grep

I was wondering if its possible to execute commands from history that match a certain regex? I know you can do something like fc 232 248 And it will go into your history and then do revisions ...
0
votes
1answer
47 views

Persistent Bash history between detached processes

I haven't yet been able to find this among the Bash documentation so I was hoping it could get answered if I asked it here. Is there any way that I can, on execution of a script, branch its history ...
0
votes
1answer
54 views

KSH on old unix systemV: search history

I have set a good ksh environement on old unix PATH=$PATH:/usr/lib/acct:/usr/sbin:/sbin:/usr/ucb export PATH EDITOR=vi FCEDIT=vi export EDITOR export FCEDIT HOSTNAME=`uname -n` HISTSIZE=500 ...
4
votes
1answer
61 views

What can cause an item to be deleted from my bash history?

About once a day, I'll run into an issue when I search for a history item in bash. Manipulating that item sometimes deletes the history entry, and sometimes doesn't. Here is one case of this ...
2
votes
4answers
281 views

Is there a way to show the history of the commands used in the shell?

If my Linux installation has three registered user accounts, is possible to check the history of the commands introduced by each one, and how?
2
votes
1answer
50 views

How can I use !! in zsh alias

I am trying to create an alias that builds upon my previous command. Say I run ag foo After looking at the list I want to be able to use those results in vim so I do vim -q<(!! --vimgrep) The ...
0
votes
1answer
110 views

How to implement command history in Linux terminal?

I am using Putty as Terminal to connect a Linux server running Oracle Linux. To use a command multiple times, I have to type that command each time. There is no function of Up and Down button unlike ...
2
votes
1answer
43 views

Why do I get different results with the same user and the history command?

I work with Linux for quite some time and have seen this behaviour but I never got a good explanation. Probably it's even very simple. If I login twice with the same user (bash) in the same server ...
9
votes
2answers
370 views

How to access the second argument from the last command in the history ?

I am starting to learn some Regex, therefore I use this command repeatedly: grep pattern /usr/share/dict/american-english Only the part with pattern changes, so I have to write the long expression ...
3
votes
1answer
64 views

Is it possible to show the current history line number when performing reverse search in bash?

Pressing Ctrl+R and typing py results in: (reverse-i-search) `py´: python I would like it to be this way: (reverse-i-search) `py´: n python where n is the history line number. I did not find an ...
5
votes
1answer
109 views

Bash: “history number” vs “command number”

While Googling how to customize my shell prompt via the PS1 variable, I'm seeing tables of special characters that can be used. In particular: \! the history number of this command ...
0
votes
1answer
33 views

append file with history line number values

Is there a way to append my_computer.sh with the command on line 330 by only referencing the line number? or with the fewest keystrokes possible? 326 pip install -U pip 327 man pip 328 cat ...
1
vote
1answer
106 views

cat .bash_history | grep ./configure [closed]

Why does this not give any output: cat .bash_history | grep ./configure on an system/in an shell where ./configure has been run multiple times. And if I use the arrow key's to scroll the history in ...
4
votes
1answer
67 views

How to protect against purge of bash history?

Following the answer: When closing multiple bash instances at the same time, there is a known race condition that may cause the history to be cleared. This occurs because there is no locking ...
1
vote
1answer
73 views

Removing passwords from terminal logs in CentOS 7

Sometimes a user gives a typo when they are trying to give a password after typing a sensitive command, such as su - . The user then will assume they are being given another password request, and ...
1
vote
2answers
78 views

How do I prevent just 'exit' from being saved when I close an SSH connection?

When searching for a way to do this on Google, all I can find are ways to quit the session without saving history (like kill -9 $$), but I have the opposite problem. I want to save all of my history, ...
1
vote
1answer
28 views

After removing the history file, why do I still have older commands in the history?

In a ssh session every time that I open it I assign a value to a variable. Then I remove history with command rm -f .sh_history. Everything is ok but why if I have other session opened and I do an ...
2
votes
1answer
63 views

How to merge duplicated history of command on terminal?

Do you have an experience like this? When you try to find a previos used command on terminal by up arrow and you find $ls # 1st time push `up arrow` $ls # 2nd time push `up arrow` ...
1
vote
3answers
338 views

how to record all who that login to my linux machines and records them

I installed the package audit on my linux red-hat 6.x machine in order to view the recored of each user that log to my linux machine yum install audit kit installation from: ...
2
votes
2answers
165 views

Export Command History into a Shell Script

Often I have complicated installation procedures to follow, like having to build dependencies for buildtools, to build dependencies for the application I wish to install from source. Once I have done ...
0
votes
1answer
37 views

Sourcing a redistributable script by default

I am creating a bash script which I wish to release on github. The script needs to access the command history but this is not possible without sourcing that script. I don't want users to put it in ...
1
vote
2answers
103 views

How do I get command name of the last executed command?

Example: I type man ls, than I want to get man only. By using !! I can get man ls but how do I get man?
-1
votes
1answer
318 views

How does this bash alias to repeat the last command as sudo work? [duplicate]

I recently came across this ingenious bash alias to repeat the last issued command, but as sudo. This could be done by using sudo !! directly in the terminal after the failed command. The alias I ...
1
vote
2answers
53 views

Why does my .bash_history contain duplicate segments? [duplicate]

Since I keep my bash history under source control, I've noticed that sometimes sizable segments of the history end up repeated, sometimes hours or days after their original execution. I use Debian 7.7 ...
1
vote
1answer
85 views

View a command in the shell history [closed]

If we put a space before any command in the shell it will not shown in history. Is there any way to see that command if the user enters a space before any command?
2
votes
1answer
72 views

HISTTIMEFORMAT syntax

There are many bash guides that include adding lines such as HISTTIMEFORMAT='%d/%m/%y %T ' or HISTTIMEFORMAT="%F %T " to ~/.bashrc or /etc/bash.bashrc. There's always a space before the final quote. ...