recall commands previously typed in a shell or other utility

learn more… | top users | synonyms

7
votes
2answers
239 views

How to stop bash editing the history when I reuse and modify an entry?

Some instances of bash change the command history when you re-use and edit a previous command, others apparently don't. I've been searching and searching but can't find anything that says how to ...
13
votes
3answers
940 views

Keep only successful commands in BASH history

Sometimes I misunderstand the syntax of a command: # mysql -d test mysql: unknown option '-d' # echo $? 2 I try again and get it right: # mysql --database test Welcome to the MySQL monitor. mysql ...
34
votes
4answers
30k views

Where is bash's history stored?

If I run history, I can see my latest executed commands. But if I do tail -f $HISTFILE or tail -f ~/.bash_history, they do not get listed. Does the file get locked, is there a temporary location or ...
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?
31
votes
4answers
7k views

How can I `alias sudo !!`?

I'm trying to set an alias for sudo !! in Bash. I tried alias sbb='sudo !!', but it interprets that as a literal !! and prints sudo: !!: command not found If I use double quotes, it substitutes ...
21
votes
2answers
886 views

What does !$ mean?

I'm following through a tutorial and it mentions to run this command: sudo chmod 700 !$ I'm not familiar with !$. What does it mean?
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 ...
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 ...
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 ...
9
votes
4answers
4k views

How to delete commands in history matching a given string?

I need to delete all commands in my history matching a string. I've tried: $ history | grep searchstring | cut -d" " -f2 | history -d -bash: history: -d: option requires an argument $ history | grep ...
27
votes
4answers
10k views

Temporarily suspend bash_history on a given shell?

Is there a way to temporarily suspend history tracking in bash, so as to enter a sort of "incognito" mode? I'm entering stuff into my terminal that I don't want recorded, sensitive financial info.
12
votes
4answers
5k views

How can I search history with what is already entered at the prompt in zsh?

In zsh, I know that I can search history with Ctrl+r. However, oftentimes I start to type a command directly at the prompt, but then realize I should be searching history. When I hit Ctrl+r, it brings ...
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 ...
6
votes
5answers
8k views

History command inside bash script

I have been bashing my head to write a simple history script for the last two days. History is a shell-built in command I couldn't able to use that within a BASH script. So, Is there a way attain this ...
32
votes
12answers
2k views

How to quickly store and access often used commands?

I have a lot of commands I routinely need to execute, often with the slightest variation. Right now I'm storing them all in .bash_history and use CTRL-R to access them, but I wonder if there's a ...
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 ...
19
votes
4answers
6k views

How can I remove duplicates in my .bash_history, preserving order?

I really enjoying using control+r to recursively search my command history. I've found a few good options I like to use with it: # ignore duplicate commands, ignore commands starting with a space ...
5
votes
1answer
737 views

Can you change timestamp format for history command on tcsh

When I run history command (on tcsh), it only prints the TIME portion of the timestamp and omits the date: 3 15:07 echo $PATH 4 15:07 ls -la In bash, you can use HISTTIMEFORMAT ...
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 ...
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 ...
24
votes
3answers
14k views

How to execute consecutive commands from history?

Suppose I want to execute a sequence of four commands that I have executed before. If the first one is 432 in the command-history, then I could do: $ !432; !433; !434; !435 I'm curious, is there a ...
9
votes
3answers
2k views

sharing or synchronizing history between Zsh and Bash

I often find myself switching between Bash and Zsh, and using the history search functionality to recover a command. However, since Bash and Zsh have different history files, I often find that the ...
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 ...
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 ...
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
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 ...
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 ...
44
votes
3answers
39k views

How to remove a single line from history?

I'm working in Mac OSX, so I guess I'm using bash...? Sometimes I enter something that I don't want to be remembered in the history. How do I remove it?
46
votes
4answers
6k views

Is there any way to keep a command from being added to your history?

Is there any way to keep a command from being added to your history? I have a command that I want to keep out of my history file, and I really don't care to have it there when I search the history ...
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
50 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 ...