Stack Exchange Network

Stack Exchange network consists of 175 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

0
votes
0answers
30 views

Seek local shell history, or ways to move .bash_history off site (ssh)?

There is no doubt that a shell history feature a la .bash_history makes it simple to keep keep track of stuff. However I do not wish to clutter an ssh account needlessly leaving a history of my ...
0
votes
0answers
26 views

show history of curl requests including executing user or program?

Little Snitch just told me that curl made a silent connection to tools.google.com. I'd like to know why. is there a way to get the history of commands on my system including who executed them?
0
votes
0answers
24 views

Accessing command history in dash

When I try to run history in dash, I get an error message. This is expected as far as I can tell. When I run fc I too get an error message like "dash fc: not found". So how do I access the command ...
3
votes
2answers
76 views

Persistent command history?

Is there a way to persist the command history and search it or group it by command? In other words, I would like to list, say every grep command I have done over the last 3 months. Is that capability ...
0
votes
1answer
18 views

Bash's history behavior when using ! and ! :p for old commands changed

Suddenly my bash history behavior changed. When I'm either calling an old command using !num (where num is the number of the commmand as seen in history) or displaying the command (without running it) ...
2
votes
1answer
48 views

History expansion in scripts [duplicate]

I have the following Bash script case $- in (*H*) echo enabled ;; (*) echo disabled ;; esac set -H case $- in (*H*) echo enabled ;; (*) echo disabled ;; esac pwd last_command="!!" echo $last_command ...
0
votes
0answers
34 views

Difference between zsh-history-substring-search and up-line-or-beginning-search

Is there a practical difference between history-substring-search-up and up-line-or-beginning-search? I've tried both out and they effectively seem to do the same thing (besides some highlighting that ...
1
vote
1answer
218 views

Bash prompt getting garbled when I browse history?

I have MacOS and .bash_profile content: export PS1="\[\e[0;31m$\]\[\e[m\] \[\e[0;32m\w\e[m\] : \]" as a result I have pwd printed in terminal like this: but when I press up and down arrows to use ...
1
vote
1answer
26 views

cycle through reverse search in a custom command history file in bash

I added a line to ~/.bashrc file which appends all issued commands to ~/.bash_eternal_history file in a date directory history-number command format, such as: 2019-01-08.23:59:32 /home/sport/...
1
vote
1answer
84 views

Changing HISTSIZE in ubuntu 16.0.4LTS

I've been trying to change the HISTSIZE system wide and it hasn't been working. I've tried multiple different methods : adding /etc/profile export HISTSIZE=100 adding /etc/enviroment HISTSIZE=100 ...
1
vote
0answers
70 views

How can I recover a corrupted Zsh history file from memory?

For reasons that partially escape me (and are outside the scope of this question), my Zsh history file became corrupt. I have several sessions open that have the history in memory. Is there a way to ...
0
votes
0answers
15 views

Possible to trigger history append (and save to file) in an already running bash process remotely?

Let's say you have a bash terminal open, in which you have typed a lot of commands, many of which are probably not yet saved in $HISTFILE. Additionally, let's say that you have a long running command ...
2
votes
1answer
50 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 ...
0
votes
1answer
37 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, ...
1
vote
3answers
90 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
65 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
50 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
48 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
28 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
45 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
85 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
310 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
379 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
447 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
101 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 ...
1
vote
1answer
119 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
92 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
890 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
62 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: ~ ...
2
votes
1answer
394 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
55 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
124 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
63 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
30 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
53 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
26 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
66 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
119 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
152 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
132 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
1k 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
194 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
44 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 ...
1
vote
1answer
121 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
40 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
391 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 tried out the following Bash command as in [1], it didn't work. history -d <line_number> How can I ...
0
votes
0answers
36 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
102 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
108 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
131 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 ...