recall commands previously typed in a shell or other utility

learn more… | top users | synonyms

0
votes
0answers
19 views

How do I merge command histories from different terminals? [duplicate]

I have one terminal in which the history looks like: 179 wget https://github.com/SIPp/sipp/archive/v3.5.1.tar.gz 180* tar -xzvf v3.5.1.tar.gz 181 ls 182 cd sipp-3.5.1/ 183 ./configure --...
3
votes
2answers
43 views

Protect session log from being written again by anyone

We have implemented a workaround to save command history in a new file for each user session for audit purpose. So each session file is identified by the start time and the username. The problem: The ...
1
vote
1answer
52 views

How to get second to last parameter of previous command in bash?

I can use Esc+. to get the last parameter of the previous command, but is there an equally convenient short-cut to get the second to last parameter?
0
votes
1answer
29 views

HISTFILE env var unset within programs. Can I access it in any way? [duplicate]

When I try to access the "HISTFILE" env var within a program, it isn't there $ echo $HISTFILE /Users/drewgross/.bash_history $ python Python 2.7.10 (default, Oct 23 2015, 19:19:21) [GCC 4.2.1 ...
2
votes
1answer
54 views

Change the key that show previous command lines in ksh

In most shells on Linux, when you press the Up-arrow key, it shows the previous command lines from the command line history. My question is, for the ksh shell, How do I set up some other key so ...
4
votes
1answer
43 views

How do I search bash's history in vi mode for “foo.*bar”

I have my bash environment in vi mode (set -o vi). So I can type <ESC>/ followed by a word, followed by enter, and bash searches for the word in the history. Since / is also vi's method to ...
3
votes
1answer
30 views

Exit status of fc -e is the wrong way around

I'm trying to edit and recall a previous command with Bash's built-in fc command, but somehow the exit status indicates failure on successful edit, even if that is a no-op. Demo: $ uname Linux $ fc -...
0
votes
2answers
96 views

How do I record all terminal input and output to a local file by default for each session?

I'm aware the script command can be used to record all keyboard input and screen output to a file, but this has to be invoked each time a terminal session is started. I keep timestamped versions of my ...
2
votes
3answers
256 views

Hide ones command history from other users on a Linux server

When I log in via ssh on a Linux(Ubuntu) server, I notice that all the bash commands executed by other users on the server are saved in the command history. Is there a way that could allow me to hide ...
0
votes
1answer
46 views

Up arrow at an empty prompt in ksh93

This is a request for explanation or pointer to documentation. I'm a KornShell93 (ksh on Mac OS X or ksh93 elsewhere) user. I like the shell for its relative simplicity as an interactive shell and ...
3
votes
2answers
39 views

Is there a shortcut to rerun a command with arguments from last command (not cd, ls or echo)

Searching through passed Logfile with something like this: cat /path/to/logfile | grep -iEw 'some-ip-address-here|correspondig-mac-adress-here' This gives me all the passed log lines until now so ...
12
votes
2answers
459 views

View a range of bash history

The history command lists out all the history for the current session. Like: 1 ls 2 cd /root 3 mkdir something 4 cd something 5 touch afile 6 ls 7 cd .. 8 rm something/afile 9 cd .. 10 ls 11 history ...
7
votes
4answers
185 views

Simplest standard way to print last bash command with timestamp

I would like to print last bash command with its timestamp. history 1 shows the history command itself. I need to use it on many machines, so it should not depend on any custom configuration. There ...
1
vote
1answer
39 views

How do we know a particular command was executed by whom?

I want to know which user has executed rm command in production server?
3
votes
1answer
55 views

Scroll to the last command on Terminal? (like OS X Terminal marks)

Mac OS X Terminal marks are incredibly useful. For example, when I type a command that echoes a lot output, it's easy to read the beginning with Cmd+Up. It will scroll to the last command and ...
0
votes
1answer
29 views

how to make sure csh won't mess up your tcsh history timestamps?

I use tcsh as my default shell. Sometimes, I run csh (e.g., for testing), and it messes up my savehist history file, particularly, the timestamps -- lots of events end up appearing under the exact ...
4
votes
2answers
64 views

sometimes history commands are not stored in .bash_history

I issued many commands yesterday in my CentOS 7. But when I wanted to retrieve these commands today, I found there was no any record. When I opened the file .bash_history, I still could not find the ...
2
votes
2answers
42 views

Use previous “path” in a command [duplicate]

A couple of years ago, a former coworker told me a trick in Bash that I completely forgot how to do it. The idea is that when you type a path, in the next command you can use some shortcut to ...
0
votes
1answer
29 views

How to prevent .bash_history from being used to rebuild history

We use custom history files which get backed up per user. When someone does a history -c we notice that after they log back in there is history in the buffer again and it seems to come from /root/....
2
votes
1answer
41 views

zsh tcsh-like history navigation

In tcsh, the \eP and \eN commands take into account the whitespace-normalized prefix of the current line, not just the first word. For instance if my history contains git pull upstream feature-...
3
votes
1answer
65 views

What does !# (exclamation hash), !$:r:r (exclamation dollar colon r), !#:t (exclamation hash colon t) mean in the below bash commands?

I have been trying to install a Nagios package and stumbled upon these weird bash expansions on a guide here. Can someone help me understand what do the expansions mean? A wiki link would also be ...
0
votes
1answer
43 views

Why there isn't a number of the command and a timestamp for fish?

In fish, when I type history | less I see the following for example: history | less export HISTTIMEFORMAT="%h/%d - %H:%M:%S " bash in bash I see this: 491 18/04/16 14:31:02 cd 492 18/04/16 ...
1
vote
1answer
58 views

Commands pasted into bash not recorded in history [duplicate]

From time to time I find that when I copy/paste a command from a web page (or from the Terminal window itself) the pasted command is not recorded in bash history. For example, just now I did this: cd ...
4
votes
1answer
39 views

What does the history command !# do?

From the manual pages on history: Event Designators An event designator is a reference to a command line entry in the his‐ tory list. Unless the reference is absolute, ...
1
vote
1answer
27 views

How do I both censor a command away from .bash_history and also be able to return to it with up arrow?

When one prepends a space character to the command, it disappears from history. But this also causes the command to no not easily editable and re-runnable. How do I make weaker version of space-...
5
votes
1answer
111 views

Clear recent open file history on Linux Mint

Sometimes others in my household briefly use my computer, when they do I sometimes don't want them to see my file history. I know how to prevent Bash from writing entries to the ~/.bash_history file ...
0
votes
1answer
78 views

Create HISTFILE in subshell

Here is my HISTFILE: $ echo $HISTFILE /home/Steven/.bash_history I can create it by using exit: $ [ -e $HISTFILE ]; echo $? 1 $ exit $ [ -e $HISTFILE ]; echo $? 0 However if I exit a subshell, ...
0
votes
0answers
13 views

searching through command line history [duplicate]

I use reverse search when looking for a particular command on the command line by pressing CTRL + R. That returns the first command it finds in reverse order. To go back to the next further command I ...
2
votes
3answers
773 views

Why can't Korn Shell do ctrl-r?

If I use PC-BSD with the default shell (Korn) then Ctrl+r doesn't work. Why won't it work? Ctrl-r was introduced to search your history in the late 1970s or early 80s and my BSD still can't do it (...
27
votes
4answers
2k views

Is there any way to execute commands from history?

For example: [root@ip-10-0-7-125 ~]# history | grep free 594 free -m 634 free -m | xargs | awk '{print "free/total memory" $17 " / " $ 8}' 635 free -m 636 free -m | xargs | awk '{print "...
1
vote
3answers
321 views

Unlimited history in zsh

In zsh, I want to have unlimited history. I set HISTSIZE=, which works in bash. Now I import an old history mv old_history .history which is pretty big wc -l .history 43562 .history If I now ...
1
vote
1answer
97 views

timestamp saved history file

I've seen a lot of documentation on how to timestamp the output of the history command. But how would you go about time-stamping a saved history file? For example I have a server setup to save each ...
1
vote
1answer
62 views

How can I access the history buffer in sh? (not in Bash)

Is there a command history in sh, for example how to access it, and as well, how to ensure it is clear? To clarify shells here: let's say you've logged on to a non-Gui Linux system, and $SHELL is ...
0
votes
1answer
34 views

How to increase history in oh-my-zsh?

I just installed oh-my-zsh for the first time. I just want to know how can I modify the number of past commands that are remembered in history? Where can I set this setting?
1
vote
1answer
63 views

how to save a command in bash history without executing it programmatically?

I have a docker container and every time I build and start it, I want just to press UP for choosing a predefined command. What's the best way to handle this?
22
votes
8answers
2k views

Clipboard for copying and pasting files in command line?

In Bash, suppose I visit a directory, and then another directory. I would like to copy a file from the first directory to the second directory, but without specifying the long pathnames of them. Is it ...
2
votes
1answer
100 views

Search bash history for already typed command

When I type ctrl+r and then start typing I can see what commands in the history match which is great. Now is there a way to search the history on commands I have already typed in the terminal? For ...
1
vote
1answer
55 views

Duplicates in bash history

I have the following in my ~/.bashrc HISTCONTROL=ignoreboth:erasedups However my history contains many duplicates e.g. I have 5 entries for sudo apt-get upgrade. I am running Raspbian Jessie and ...
1
vote
1answer
119 views

zsh HISTFILE - still read from ~/.zsh_history

I set my $HISTFILE env var to something custom, and my zsh is indeed writing to the new histfile. But when using up-arrow or other history-searching capabilities, it still reads from ~/.zsh_history. ...
1
vote
0answers
38 views

history shows only current session

This is what I see in my terminal in a fresh session: Agent pid 6847 Identity added: /home/eric/.ssh/id_rsa (/home/eric/.ssh/id_rsa) ➜ ~ history 1 history ➜ ~ I'm using Linux Mint 17.3 ...
1
vote
1answer
26 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
43 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
115 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
150 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
78 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
70 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
129 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
25 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
40 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
29 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 terminal,...