Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [command-history]

recall commands previously typed in a shell or other utility

1
vote
1answer
43 views

find commands too old for history

I am trying to find commands executed on my xen server yesterday - but the oldest command to be seen with history dates from today. Is there a way to see older commands (history displays 380 latest ...
-1
votes
1answer
32 views

Who have previously accessed a shared file?

I just discovered a mistake in the permissions setting of our system. It's kind of serious because it allows normal users to access something they shouldn't see. Currently the mistake has been fixed, ...
0
votes
3answers
38 views

Merge multiple .bash_history files with timestamps

I have generated multiple .bash_history files by switching between snapshots on a VM. I would like to recover all these files into the single live .bash_history file in my currently running instance. ...
0
votes
2answers
55 views

Delete history from 100 to 150 entries in bash shell

I want to delete history but not fully, suppose I have total 200 entries in my history and I want to delete from 101 to 150. Is this possible ? I have seen multiple methods to delete history like ...
2
votes
1answer
24 views

zsh: populate search input with existing line contents when ^R is pressed?

Given .zshrc config: bindkey -v bindkey "^R" history-incremental-pattern-search-backward When I type foo<^R>bar at an empty prompt, it searches for the most recent command matching bar. How ...
1
vote
4answers
47 views

Is there a way to tell how many commands I've run since I ssh'd / logged in, in bash? [duplicate]

I run the history command in bash but it gives me everything... I noticed that I'm able to limit the number of previous commands displayed by running history | tail -n <num-of-lines+1>; so is ...
1
vote
0answers
22 views

Shared and non-shared history together

Using zsh (in tmux), I would like to access the session history with Up and the shared history with Shift+Up (or similar). Does anybody know how this could be achieved?
1
vote
0answers
16 views

Customize ZSH history search in vi mode

I want to replace default history search widget in vi mode with my own (binding it the the default key, i.e. / in command mode). Here's what I tried putting in my .zshrc: custom_command() { ...
3
votes
1answer
56 views

Zsh: consistent history between machines

Use case: distribute zsh's history between machines in source control. Is that something that I can achieve with zsh's history -- put history in version control the sync between mahcines? This is to ...
-1
votes
1answer
35 views

Get command history from remote user on Linux server [closed]

I have a Linuxserver(CentOS) and many users can access this by ssh. I need to get all history commands from users: Date: the time of execution Pwd: executable directory Remote host ip User Command
0
votes
1answer
46 views

history + display date and time for each command [duplicate]

we have redhat Linux machine version 7.2 when we type history we get the history but without date and time 1 ifconfig 2 cd /etc/udev/rules.d/ 3 ls 4 cat 99-vmware-scsi-udev.rules ...
1
vote
1answer
92 views

How to see command history log from SSH

For some reason I can't see the command history log if someone ssh's into my account and runs some commands from my user account. If I run the history command in the terminal I only see my own ...
2
votes
0answers
69 views

how to avoid writing failed bash commands to bash_history

I'm looking for a nuanced history behavior I haven't seen anywhere. During a terminal session, I want every command, regardless of exit status, to be appended to the in-memory history. Upon exiting ...
0
votes
1answer
28 views

history -a not working in bash

Am I doing something wrong? I think I'm following the directions in the man page, and it's just not having any effect. [501] $ history | tail 492 echo 3 493 echo 4 494 echo 5 495 echo 6 ...
0
votes
2answers
78 views

Is there something like cat with history?

It's about a program that works iteratively - gets input from stdin and pass the results over the stdout. There is a set a know text that need to be passed to this program and I've put them in a file ...
0
votes
2answers
325 views

Cut command Error: the delimiter must be a single character

I am trying the following command on bash-4.3 $history | grep history | xargs cut -d ' ' -f1 but i am getting the following delimiter Error that I can't get rid of cut: the delimiter must be a ...
2
votes
1answer
33 views

Rerun previous command immediately in zsh instead of creating it

I know I can re-run a previous command using !!, but doing this in zshell only grabs the command and puts in on the new line, which requires me to press enter again to execute it. For example: ~ ...
1
vote
1answer
135 views

Some commands not working when executed via ssh while redirecting output locally

I can run the following two commands for example and get the output locally: ssh user@remote.ip ls > testhistory.txt ssh user@remote.ip "cat .bash_history" > testhistory.txt But if I run ...
0
votes
1answer
42 views

History inside a Bash Loop

I'm using bash to execute complex scripts having for and wile loops. I activate the history in the script using : set -o history -o histexpand But if I execute the following script: #!/bin/bash set ...
2
votes
2answers
51 views

Alternative of bash's `history -p` in zsh?

In bash, history -p does history expansion on its argument; What is the alternative in zsh?
3
votes
1answer
40 views

How can I alias a history expansion in zsh?

I want this to work (it needs extendedglob and histsubstpattern): alias ri='^(#b)E(?)^E${(l:2::0:)$((match[1]+1))}' But it doesn't: $ alias sss='^(#b)E(?)^E${(l:2::0:)$((match[1]+1))}' ...
1
vote
1answer
26 views

How can I increase a number found by wildcard in the previous command? (zsh)

I want to accomplish this: setopt HIST_SUBST_PATTERN echo Ninja_Turtles_2003_S02E05_DVDRip_30NAMA.mkv ^E(0?)^E$((match[1]+1)) # resulting in: echo Ninja_Turtles_2003_S02E06_DVDRip_30NAMA.mkv ‌But I ...
2
votes
1answer
29 views

restricting hist_verify in zsh

Is it possible to bypass hist_verify for specific history commands? For instance, I rarely have the need to verify !$ or !!, whereas I find verification to be a useful feature for more complicated ...
0
votes
1answer
25 views

Show/hide history index in console

Via Putty, i log onto a SuSe linux machine. Suddenly, a percentage value appeared behind the commandline. Looks like that: [<DOMAIN>\<USER>@<HOST>:/home] 544% It seems the value ...
1
vote
2answers
48 views

Is it safe to edit ~/.bash_history “live”?

bash stores a user's command line history in a plain text file "~/.bash_history". Assuming only one user is using a single terminal, are there any bad side effects of opening "~/.bash_history" in a ...
2
votes
0answers
81 views

history -c does not reset $HISTCMD to 1

TL;DR: If your history begins to truncate (e.g., your HISTSIZE is 400 but your history number is 500), resetting your history with history -c will clear HISTSIZE or fewer lines from your history, and ...
2
votes
0answers
143 views

How do I call current “.bash_history” from a script?

There is a program called "thefuck" that you can install and it uses python to take the last command you ran and give you ...what you probably meant. It's a cool program. I wanted to create a script ...
1
vote
1answer
65 views

Is $PROMPT_COMMAND a colon separated list?

I want to enable my command history across all terminal tabs and windows to be recorded in .bash_history by setting PROMPT_COMMAND in .profile: export PROMPT_COMMAND="history -a; history -c; history -...
3
votes
1answer
480 views

Sending bash history to syslog

Bash version 4.N has apparently the ability to write command-history to syslog, but I can't find information about how to configure this. I have read several pages which offer hacks using the ...
1
vote
2answers
142 views

How can I permanently correct a typo in my last bash command?

It's not uncommon that I make a typo when entering commands in my bash interactive shell. I'd like to be able to correct the typo in my bash history so that the incorrect command does not pollute it ...
0
votes
1answer
35 views

strange history command with tput

I have this line which keeps appearing in my shell history even when I am not internet connected : cd some_directory && tput cuu1 && tput el Does anyone knows what it does and where ...
0
votes
0answers
61 views

Python command history when piping into tee

I want to use tee with python and still be able to use command history when in interactive mode. So whitout tee I can do the following: $ python Python 3.6.5 (default, Apr 30 2018, 16:04:33) [GCC 7....
1
vote
1answer
73 views

migrating zsh_history to .bash_history

I migrated from mac to linux I backed up my zsh_history.txt How can i merge/append it to my .bash_history file? I see the format is different: git pull #1530441990 git push #1530447814 locate "*ls*...
0
votes
1answer
32 views

Debian terminal - how can navigate from history list?

I want to use Ctrl + r to navigate in commands history, but I want to see all list of commands. I want to view the list of history | grep some-term commands and going "up" or "down" choose the proper ...
0
votes
1answer
120 views

How to remove a single command from TCSH history?

I'm trying to remove a single command from TCSH history on RHEL 6, but couldn't find a way. I desperately tried out the following Bash command as in [1], it didn't work. history -d <line_number>...
0
votes
0answers
30 views

Wrap the history number - reset history number without losing history

I display the history number as part of my prompt, e.g., {!1123}(j:~)$ ls /some/long/and/hard/to/type/path so that I can do it later with !1123. My HISTSIZE and HISTFILESIZE are both 200, but this ...
2
votes
1answer
74 views

Possible to make zsh up-arrow history search detect aliases?

I have git aliased to g. Sometimes I use g, and sometimes I don't. I might run git add file1 and later g add file2. When I want to add file1 again, I might type g add in the zsh prompt, and then ...
2
votes
2answers
87 views

How to import bash history with correct time&date from a history output?

I have a file with my bash history and want to "import" the commands on a new machine. The file contains a history output formatted as HISTTIMEFORMAT="%F%t%T%t": $ history > history.txt So the ...
1
vote
0answers
69 views

`history` command produces asterisk * entries

My modified search history lines have an asterisk next to them. I've searched unix.stackexchange.com and stackoverflow.com, but I yearn for a full explanation for the asterisks in my history (other ...
2
votes
1answer
46 views

Return last command executed in bash function

Similar to this: Return last command executed in shell-script. lastCommand=$(some command here) Is it possible to achieve same result, but instead used inside a bash function, not a bash script? P....
1
vote
1answer
41 views

Turn flushing history in ksh after each command (or stop refreshing it)

I have read that ksh, in contrary to bash, flushes its history after each command. This may be good for many, but for me, it drives me nuts! I have several windows opened that are opened for their ...
0
votes
1answer
43 views

How do I make my bash login session “autosave” its history? [duplicate]

IIANM, bash saves its history to ~/.bash_history (or to $HISTFILE) on exit from a login shell session. But - what if you want to occasionally persist it for fear of the shell getting prematurely ...
0
votes
3answers
24 views

search the pattern and replace the value in a file

/home/digadm02/.bash_history:#1520325239 /home/digadm02/.bash_history:sudo su I have these kind of lines in file test.txt. I have to search the pattern of "#1520325239" and replace them with the ...
1
vote
0answers
30 views

How do I clear a suggestion from history-beginning-search-backward or history-beginning-search-forward?

How do I clear a suggestion when history-beginning-search-backward is invoked? For example: sudo vim #history-beginning-search-backward gets executed by a keybinding sudo vim /etc/hosts Once in ...
1
vote
1answer
36 views

Entering . (dot) cancels zsh incremental history search

History Search Ctrl+R in my zsh cancels if I enter the dot . character. If I hit Ctrl+R the bck-i-search: prompt appears and the history is searched according to the words I enter. But as soon as I ...
-1
votes
1answer
105 views

Why is my zsh history file not being written after each event?

I have this in my .zshrc: setopt -o sharehistory HISTFILE=~/.histfile.$TTY:t HISTSIZE=500 SAVEHIST=$HISTSIZE My understanding of sharehistory is that this would cause the HISTFILE to be updated ...
0
votes
0answers
140 views

csh: history command numbers out of whack

I'm forced to run csh and I'd like to accomplish two things: Merge command history between multiple sessions and have the history available across all sessions (not just after logout). Format the ...
0
votes
1answer
186 views

IBM AIX cannot view history in bash shell

The AIX user I su to daily has no history from SSH session to SSH session. I'm using the bash shell because the Korn shell alternative does not autocomplete which is an even bigger nuisance. I ...
0
votes
2answers
373 views

Can I do the equivalent of tail -f for bash history?

I'd like to be able to watch the history of a user, but in real time. My first thought was to use tail -f to track whatever file updates the history. Is this possible? Or, is there a better ...
3
votes
1answer
202 views

KSH history weirdness

First time posting here, so bear with me... I'm running KSH on RHEL 2.6 on x86. KSH version is: sh (AT&T Research) 93u+ 2012-08-01 Switching to Bash or back to Tcsh (which I happily used at my ...