recall commands previously typed in a shell or other utility

learn more… | top users | synonyms

0
votes
0answers
18 views

Can I make history not print any timestamps for commands that were run before I enabled that option?

If you run history, it outputs the current date before commands that were run before I enabled timestamps, is there anyway I can make it ignore that? For example, if my .bash_history looks like this: ...
1
vote
0answers
16 views

Can I prevent zsh slowing with a large history?

I've just migrated from bash to zsh. I converted ~/.bash_history for use in zsh. It's 150 000 lines long. bash is almost instantaneous to start up, but zsh is now fairly slow, taking half a second to ...
1
vote
1answer
47 views

Implement a shell in a bash script [closed]

I am trying to emulate a shell in a bash script, like this: cmd_shell() { while true; do read -e -p 'pass> ' command run_cmd $command done } It works ok, and the option ...
1
vote
2answers
22 views

How to get the previously used command in HP-UX reverse search

I'm using HP-UX OS and want to use previously typed command, as how I'm using in Linux Ctrl+r for ease access in the HP-UX command line.
3
votes
4answers
67 views

Sticky entries in shell history

Is there a way one could make some commands "sticky" in a shell history? I want to save some favourite commands that would be searchable with Ctrl+R, like the rest of the history, but they should ...
0
votes
1answer
18 views

bash-like last command in history using up-down arrow keys in zsh [duplicate]

In bash, we can use the up and down arrow keys to get the last or nth previous command in history. Can we do this in zsh?
1
vote
2answers
39 views

Echo & redirect bash history !commands to file

Is it possible to echo and redirect history commands into a script file by the ! command? Is there variation of the pipe, redirect, or tee commands I am overlooking? 518 xmodmap -e "keycode 66 = ...
0
votes
0answers
23 views

Linux Bash History - eliminate/stop specific command from being stored in history [duplicate]

I have shared history (very large history too) setup in my .bashrc file (see below for my .bashrc). I also have PRTG monitoring (uptime monitoring and graphing, like MRTG) of my many linux/centos ...
1
vote
0answers
39 views

Variables in history?

Is it possible to include environment variables in the history output. Something along the lines of: %T %F $SUDO_USER $HISTORY_COMMAND 1 2015-01-01 00:00:00 USER123 echo 123 Reason being we have a ...
1
vote
1answer
27 views

Is there any way to list the latest GUI transactions in Linux?

Suppose that I've moved a directory in my Xfc desktop in another directory, which I can't remember the name of the destination directory. Is there any way to list the latest transactions in ...
0
votes
0answers
19 views

How to remove duplicate entries from bash history? [duplicate]

I have set: $ echo $HISTCONTROL ignoreboth:erasedups and expected by the value of erasedups for all my duplicates entries to disappear from my bash history. Yet when calling cd a few time, I still ...
4
votes
2answers
60 views

Inconsistent Bash history

On this Debian Jessie installation, Bash history seems to be behaving inconsistently in Gnome Terminal: $ echo $USER me $ echo $HISTFILE /home/me/.bash_history $ grep browser ~/.bash_history ...
0
votes
0answers
18 views

Bash previous command refresh is messed up [duplicate]

I'm running on a mac with el Capitan. I'm at the command prompt, running bash. When I hit the up-arrow, sometimes it's as if it thinks that my prompt is much longer than it is? The first part of the ...
1
vote
2answers
52 views

What is in a new terminal window's command history?

If I open a terminal window (Gnome terminal 3.6.2) and type a command, say echo "hello", then open a new terminal window and type <Ctrl>Rhello, I might expect to be able to dig this command out ...
2
votes
2answers
74 views

Can't get “echo !!” to work in bash from a saved script

I'm trying to write a simple script to take a previous command that was (accidentally) written in a non-English layout, convert everything into correct symbols and run it. I'm using Bash 4.3.11. My ...
3
votes
3answers
59 views

How to make Bash flush command history so it can be cleared?

I accidentally put a password on the command line and needed to clear Bash shell history. That was easy enough with echo "" > ~/.bash_history. I added the same to my .bash_logout just in case for ...
3
votes
1answer
75 views

Replace the last word of last command but keep the first

Assuming I have a script for grepping through a bunch of files with certain options and run this script with many different words: $ mygrep worda [output] $ mygrep wordb [output] $ mygrep wordc ...
27
votes
2answers
1k views

What does !#:3 mean in a shell command

The install guide for ack suggests installing the ack script using this command: curl http://beyondgrep.com/ack-2.14-single-file > ~/bin/ack && chmod 0755 !#:3 I assume that the !#:3 at ...
3
votes
4answers
107 views

How to remove the last command (or current command for bonus) from zsh history

Sure there's a super simple smart way to do this, but since history in zshell seems to be aliased to fc, there's no way to use the tricks mentioned in How to remove a single line from history?. Any ...
2
votes
1answer
71 views

fish: sudo: !!: command not found

I have fish installed in my Linux Mint DE. I really like how fish makes things easier and it looks so pretty although I haven't find a correct answer about why I can't execute: sudo: !!: command not ...
12
votes
5answers
864 views

How to recall a previous command (without execution) in order to change it?

I can't remember the trick where I could get the last command without running it: let's say I want to be be able to access the command !1255 when pressing the up arrow key and modify the command. So ...
5
votes
5answers
944 views

Where is the log of used commands in Linux?

In Linux, generally we use a lot of commands and it is difficult to remember all of them. history command provides the list of commands we used previously but its limit is less. New commands are ...
17
votes
6answers
927 views

Search for a previous command with the prefix I just typed

We can use up and down arrow to navigate in command history. In some IDE, such as matlab, if we input sth and then press the arrow keys, we stroll among only the history commands starting with what ...
1
vote
1answer
30 views

Some confusion about the working mechanism of ~/.bash_history

I'm confusing about the content in ~/.bash_history when I worked on several terminals. How does it work on saving the history in different terminals?
0
votes
0answers
36 views

reverse-i-search (Ctrl-r) with history -r?

I'm searching a way to reload the bash history before executing "Ctrl-r" command. Or better, complete using the .bash_history instead of the in-memory dump. Every Terminal has its "own" history but ...
0
votes
1answer
51 views

Where is zsh storing my history?

I have two terminals open, both running zsh. The history options which I currently have set are these: export HISTFILE=~/.histfile export HISTSIZE=10000 export SAVEHIST=10000 setopt ...
3
votes
2answers
144 views

Can I delete .bash_history without sudo?

I don't want it to do it to my system, But I am wondering , is it possible to delete .bash_history ? And if yes, Then can you bring it up again or there will be no history ever again ? Also, Is the ...
2
votes
1answer
116 views

.bash_history vs history command

When I open my .bash_history file and view my previous commands via the history command, I see that they are not the same exact commands ? I feel like the .bash_history commands contains less ...
1
vote
1answer
51 views

Can up arrow command history for oh-my-zsh narrow down history by options/parameters given to the command

Not sure I'm wording the question very well, but an example is worth a thousand words of mine. eg., using oh-my-zsh : git <up arrow> Will cycle up all the git commands I have used... git ...
6
votes
1answer
54 views

How to revert from searching to original command

Following the instructions here, I edited by .bash_profile to enable the up and down arrows to autocomplete what I have typed in the shell based on previous commands. I added to my .bash_profile: # ...
4
votes
1answer
83 views

How do I abort fc without executing the command?

The command fc will allow visual editing of the previous command. If I change my mind in the editor, how do I stop the command from being executed. In vim, typing q! or q both result in the command ...
1
vote
0answers
70 views

Why does history not overwrite but append when histappend is set to off in Bash?

Several days ago, I had one Terminal tab doing ssh, and the other doing a lot of work locally. And then I restarted the machine (on a Mac with Mavericks). When I ran Terminal again, I found that all ...
0
votes
1answer
29 views

Can I make sure history logs all execution?

Please forgive the ambiguous nature of this question but I was wondering if there's a way to make sure that all commands executed by some host are logged into history. In my case, if I send a command ...
2
votes
3answers
104 views

Grab the last executed command from history as a string and store in variable in bash

I'm trying to grab the last executed command, with options, and store it as a string to be written to a file. I've tried using fc but that can only give me the next to last command (for me anyways) ...
6
votes
4answers
79 views

How to repeat a command with an added parameter

I know how to repeat a command and add more text after it with !! like so: ls -l !! tmp The second line expands to ls -l tmp. But what if I wanted to add parameters to the command in between the ...
2
votes
0answers
62 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
74 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
87 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
365 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
478 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
274 views

Update bash history on other terminals when exiting one terminal

I know this question is not obscure, as it is asked here keep updating (and duplicated here). What I'm trying to achieve is a bit different. I don't like the idea of my prompt rewriting a file every ...
1
vote
1answer
97 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
107 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 ...
2
votes
2answers
174 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
386 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
33 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
129 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
98 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
33 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
235 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 ...