recall commands previously typed in a shell or other utility

learn more… | top users | synonyms

2
votes
1answer
28 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. ...
130
votes
11answers
38k views

Preserve bash history in multiple terminal windows

I consistently have more than one terminal open. Anywhere from two to ten, doing various bits and bobs. Now let's say I restart and open up another set of terminals. Some remember certain things, some ...
0
votes
0answers
33 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 ...
3
votes
1answer
127 views

Search Alt+F2 history in Cinnamon desktop environment

I wonder if there's some way to search the Alt+F2 "runner" history most preferably within the dialog itself. I know that in Cinnamon the values are available in dconf-editor under org.cinnamon ...
2
votes
3answers
497 views

“history” stops working when run inside bash script

I am writing a simple script to grep my bash history to find a particular string. On the command line, I can do the following, which works fine: history | grep git However, when I create a bash ...
8
votes
5answers
2k views

How can I save the last command to a file?

When I am running my analyses using the bash shell, I often want to save the commands I've used that gave me good results to a file in the same directory (my "LOGBOOK", as its called) so that I can ...
0
votes
2answers
49 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
38 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
41 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
184 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
50 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 ...
1
vote
3answers
503 views

Different “history” command output after reconnecting via SSH

Why do I get different results for the "history" command for the same user after I reconnect a disconnected SSH session? I connect to a server using putty (SSH), say as root My network gets ...
2
votes
1answer
79 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? ...
1
vote
1answer
194 views

How to check the time at which the command was executed?

When history command is executed, it shows a list of recently executed commands. Is there any provision with which we can see the time at which those particular commands were executed?
14
votes
2answers
4k 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 ...
1
vote
2answers
1k views

Extending history search in zsh

How to extend Ctrl+R search in zsh? It cannot find entry despite it is in history file. Edit: My .zshrc: setopt AUTO_CD setopt CORRECT_ALL setopt EXTENDED_GLOB # History SAVEHIST=10000 ...
1
vote
1answer
21 views

Partially duplicated history when setting PS1 in .bash_profile [duplicate]

When I set PS1 variable in ~/.bash_profile, it worked as configured. However, the history is somehow messed up. When I press Arrow Up or Ctrl+P to view commands I typed, it starts to duplicate ...
4
votes
3answers
265 views

How do I auto complete a command from the command history? [duplicate]

Is there a key combination for bash to auto compete a command from the history? In ipython and matlab for example this is achieved by pressing up arrow after typing a few characters.
34
votes
2answers
2k views

How do I open an incognito bash session?

Is it possible to open an incognito session in bash? For example, when we need to enter passwords in commands and don't want bash to add them to history.
4
votes
3answers
537 views

Why does bash have a HISTCONTROL=ignorespace option?

Or to phrase it differently, why would you want to prevent commands from being written to the bash history? (Inspired by a related question.)
7
votes
1answer
86 views

history - List only successfully run commands

I'm wondering if there's a way to use the history command but only list commands that were run successfully. Likewise, would there be a way to list ones that produced errors? I know each command has ...
18
votes
2answers
2k 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 ...
1
vote
0answers
91 views

HISTSIZE HISTFILESIZE not working [closed]

I have set these global variables in my .bashrc file Running echo $HISTSIZE echo $HISTFILESIZE both return 10000 My History contents are overding, currently from 254 - 432 If I type another two ...
5
votes
0answers
67 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 ...
2
votes
1answer
64 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 ...
0
votes
0answers
31 views

What does !$ mean exactly? [duplicate]

echo !$ outputs different strings depending on my previous command line call. For example: mrdumbdumb-redhat:~ mrdumbdumb$ ls mrdumbdumb-redhat:~ mrdumbdumb$ echo !$ echo ls ls ...
5
votes
2answers
201 views

echo of a string with an exclamation point

Here are what I put in bash and the results I got about 'echo': $ echo '!$' !$ $ echo "!$" echo "'!$'" '!$' I'd like to know how 'echo' deals with the second input. It seems to me that ...
3
votes
2answers
954 views

Keep all commands in bash history?

I have the opposite question to this. How do I keep all commands in bash history? In Ubuntu since quite some time now, the default for bash is to forget commands with non success exit code. This is ...
2
votes
2answers
53 views

Livesearch with first 10 matches as preview for zsh-history?

I have seen a history-livesearch with a preview, that shows the 10 first matches in the history in a list below the BUFFER-line, which is updated on every keystroke, and acts like the standard ctrl+r ...
4
votes
4answers
113 views

Bash history in script: `!#:*`

I have been reading through the study guides for the LPIC-1. echo "This is a sentence. " !#:* !#:1->text3 I'm having trouble understanding how the above line of code repeats the echo command ...
7
votes
2answers
268 views

Is there a shortcut for repeat the second proximate command in bash?

We all know that !! can repeat the last command you do in bash. But sometimes we need to do some operation like $ python test.py $ vim test.py $ python test.py # here is where I need to repeat the ...
3
votes
4answers
644 views

Shell: How do I get the last argument the previous command when it was detached?

Within the shell, typing ALT+. or using !$ recalls the last passed argument of the previous command. I use this all the time, but how do you do that when you detached the previous command? $ ...
2
votes
2answers
107 views

Is there any way to undo a bash history modification?

By pressing up, I can go through previously entered commands. I've noticed though that if I modify one of them, that alters the history. For instance, if I type: echo a echo b echo c ...
3
votes
2answers
119 views

Show older or newer history items with the history command in zsh

I typed in the history command and it showed me the last 10 commands executed by me. Now I wanted to see the last 20 commands executed by me so (after reading the documentation): An argument of n ...
3
votes
1answer
70 views

Persistent directory stacks across sessions in zsh

I would like to share my directory stack (the one accessed with dirs) across sessions and tmux panes/windows. In the zshbuiltins man page I have found autopushd to add every directory I switch into ...
17
votes
8answers
3k views

How do I repeat the last command without using the arrow keys?

I know I can use Up to iterate through previous commands. Running the last command simply involves Up + Enter. However, I was thinking of buying the Happy Hacking Keyboard as I spend a lot of time in ...
2
votes
1answer
169 views

How does execution of !find command work?

The !find command lets the user perform the previously executed find, with all its parameters. How does it work internally, where exactly has this behaviour been programmed?
6
votes
6answers
671 views

How can I reproduce commands run on one machine on another machine?

I would like to install some software on a linux-machine that I have run in VirtualBox. Then I would like to do the same thing on a linux-VPS. I think that I can save all commands that I run using ...
1
vote
3answers
53 views

Command to 're-apply' previous command?

Is there an easy way to re-apply a previous command to a new command line entry? Say I typed in chmod u+r,g+x file.txt but forgot the sudo. Could I simply type sudo <some easy symbol>'? ...
2
votes
1answer
30 views

Is using shorthand quick substitution of history expansion problematic?

In my terminal (bash 3), I sometimes use the quick substitution ^aa^bb^ ^string1^string2^ Quick substitution. Repeat the last command, replacing string1 with string2. Equivalent to ...
5
votes
2answers
329 views

Why does !! inside an alias not work?

I have this alias set in my system /etc/bashrc file: alias root="sudo !!" The intention of this being to run the last used command using sudo of course. When used, it of course appears to ...
2
votes
1answer
69 views

Ctrl-R style interactive search in custom file

I want to be able to search a custom text file similar to the interactive history search in bash. Once the wanted entry is found, executes the line. Bonus Points: have each record contain two ...
16
votes
3answers
2k 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 ...
6
votes
4answers
2k views
1
vote
1answer
73 views

Searching history forward after backward?

In bash, when I hit Ctrlr, I can search the command history backward. If I would like to search forward again, what shall I do? I hit Ctrls, but it doesn't work. My bash is GNU bash, version ...
1
vote
2answers
71 views

alias for a command using !! to recall the last command [duplicate]

This is a follow-up question to Execute a line of commands with one sudo If you want to redo the same command with sudo !! after doing a command like this: echo "something">/path/file You ...
9
votes
3answers
2k views

Execute a line of commands with one sudo

For example if I want to create a file and enter text in one line I can redirect the output into a file with the use of the > operator: echo "something" > /path/foobar but if I don't have ...
2
votes
1answer
166 views

History in the Almquist shell in the NetBSD

In NetBSD /bin/sh is a modified version of the Almquist shell. With the command fc -l it is possible to view the last 16 commands typed in the prompt in the current session and not the older ones. ...
3
votes
3answers
405 views

Automatic cleanup of Bash history

How can Bash history be automatically cleaned up? For example Remove detectable typos from history (ls-lh does not show up in which, so it is removed, I meant to type ls -lh) Clean excessive spaces ...
2
votes
1answer
3k views

How do I set an unlimited size to the history file for tcsh?

This is a follow-up question to Is there a maximum size to the bash history file?. Unfortunately, it doesn't work with the atmospheric science department computers, as they use tcsh rather than ...