recall commands previously typed in a shell or other utility

learn more… | top users | synonyms

1
vote
1answer
54 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 ...
12
votes
1answer
126 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
38 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
52 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
50 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
26 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
51 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
34 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
17 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
145 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
90 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
18 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
132 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
81 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
58 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
16 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
0answers
36 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
30 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
102 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
59 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
41 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
40 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
58 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
278 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
46 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
91 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 ...
9
votes
2answers
323 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
58 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
95 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
32 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
92 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 ...
3
votes
1answer
60 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
62 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
70 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
27 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
53 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
264 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
138 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 ...
1
vote
2answers
94 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
275 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
51 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
84 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
65 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. ...
0
votes
0answers
41 views

Bash ignore “update” command

I have this in my .bashrc export HISTTIMEFORMAT="%Y/%m/%d - %H:%M:%S - " export HISTIGNORE="&:[ ]*:reload:update" export HISTCONTROL=ignoreboth:erasedups shopt -s autocd shopt -s cmdhist shopt ...
1
vote
2answers
168 views

bash history for current session

Maybe I'm overlooking something but is there a way to get your current bash history for the current session you are using like if i run ssh host $ pwd $ ls $ cd /tmp I just want to see those 3 ...
0
votes
1answer
105 views

What does “dd” stand for? [duplicate]

What does dd stand for? I've always referred to it colloquially as "Disk Destroyer", but what are the "official" words that make up the acronym/command? According to this link and this link it could ...
0
votes
1answer
57 views

.bash_history keeps truncating

My .bash_history keeps truncating even though I set: export HISTSIZE= export HISTFILESIZE= On my .bash_profile. Im not sure when it happens but it might happen when I logout or shut down my ...
4
votes
4answers
606 views

How to capture command line input into logfile and execute it at the same time?

Let's say I issue some commands on the command line: #capture what follows $ echo "foo" foo # don't capture $ echo "bing" bing # capture again $ echo "bar" bar How can I log commands selectively ...
0
votes
1answer
87 views

How to list down all useless or less used files or application in my linux server?

I want to clean cruft from my Oracle Linux server. For this, I need to know which application or directory isn't used or is hardly ever accessed. Is there any command or way to list directories or ...
2
votes
1answer
220 views

Never clear .bash_history (HISTFILE)

Is there any command that I could use that makes .bash_history never clear itself? After a certain amount of commands it just clear itself. I think this works but I'm not sure? ...