recall commands previously typed in a shell or other utility

learn more… | top users | synonyms

11
votes
3answers
726 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 ...
1
vote
1answer
54 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
43 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 ...
8
votes
3answers
431 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
44 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. ...
5
votes
3answers
222 views

How to have command history with timestamps output to the terminal continuously?

I use a simple alias to enable the "tracking" of commands in one or many terminal window(s): alias trackmi='export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"' Then I just tail -f my .bash_history ...
1
vote
1answer
76 views

Recover my history of past commands?

Always when I turn on my Fedora 18, my history command disappear. How can I recovery all my history since I installed my OS? In my ./bash_history show olny the command of the day when I turn off ...
1
vote
2answers
65 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 ...
1
vote
1answer
168 views

How to sync terminal session command history in bash?

I've tried to search in ~/.bash_history for my recent commands while in a terminal session but they just weren't there. I guess this is because I have multiple terminal sessions open. Is there a way ...
2
votes
1answer
95 views

Commands run when terminal is open do not appear in history

I have the simple following terminal.sh script: #bin/bash --login str=(--tab --title="Test" -e "bash --login -c 'echo history';bash") gnome-terminal "${str[@]}" exit 0 I basically use it to open a ...
0
votes
1answer
28 views

openSuse, linux, chmod to change link's permisions

I am trying to change the permissions for the link. I want the "Other" entity to have only the read permission, but when I run the command the permissions are not changing. Is there something I am not ...
2
votes
1answer
27 views

Duplicates in history file even after HISTCONTROL specified

I am using cygwin with bash (on Windows 7 pro). I have the following in .bashrc: # Don't put duplicate lines in the history. export HISTCONTROL="ignoredups" and the following in .bash_profile: # ...
3
votes
1answer
265 views

Why does the history command do nothing in a script file?

If I create a file containing #!/bin/bash history and run it, I get no output. Running it manually in a terminal or sourceing the script file does produce output. Why does history not work from ...
0
votes
1answer
48 views

where does history timestamp stored before i enable it

I tried to set timestamp for history. My first attempt was do export EXTENDED_HISTORY=ON command, and it seems like doesn't work. Then i do echo 'export HISTTIMEFORMAT="%d.%m.%y %T "' >> ...
2
votes
3answers
135 views

How can I get the last line number of unique commands when grepping my history file?

I rely on my history file for previous commands, especially ones that are long with many parameters. Once I find the command and its line number(nn) I use !nn to run it. I prefer to see the full ...
2
votes
1answer
47 views

How to use quick substitution to replace all the strings of the previous command? [duplicate]

I know I can replace a string of the previous command using ^old^new. But it seems to only replace the first occurrences as I do the follow: $ cat /proc/5742/task/5742/status ... $ ^5742^2839 cat ...
7
votes
7answers
564 views

Find out what command I last ran that starts a certain way?

On bash commandline environment, you can do !! to rerun your last command. And you can press up arrow to see the the last command you ran. But what if you want to only see but not run the last command ...
4
votes
1answer
175 views

Why do piping and redirection work differently with here documents?

Combining a redirect with a here document seems logical enough: $ bash > foo <<EOF echo Hello EOF $ less foo Hello But with a pipe it behaves differently: $ bash | tee foo <<EOF ...
17
votes
2answers
618 views

^x^y unix trick for all instances in last command?

One of my favorite Unix tricks is ^x^y, which will take the last command and replace the first instance of "x" with "y". However, I'm wondering if a similar trick works to replace all instances of "x" ...
2
votes
3answers
84 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.)
11
votes
1answer
199 views

Why is bash not storing commands that start with spaces?

If I perform a sequence of commands like: $ ls $ grep abc file.txt and then use the up arrow key to get the previous one, the terminal will show the last cmd (which is the grep here) But if I do ...
0
votes
1answer
39 views

Using !n in script or interactive mode

I add to ~/.bashrc the following code: test_exclamation () { printf %s "$READLINE_LINE" | xargs echo } bind -x '"\eX": test_exclamation' I write to bash prompt buffer $ !1700 If I press Enter, ...
1
vote
3answers
73 views

Copy command from history to bash prompt

Sometimes I'd like to get some command from history output, copy it to bash prompt, make some changes and run it. Is there a way to copy command from a history output to bash prompt without involving ...
3
votes
2answers
204 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 ...
1
vote
1answer
36 views

Unable to make .zhistory a symbolic link

Every time I try to make my Zsh history file (.zhistory file) a symbolic link to a file (previously existing .zhistory file) that lives in another folder, Zsh deletes the symbolic link and makes it a ...
2
votes
1answer
482 views

Command history in Zsh

How does Zsh keep track of command history? I see two files in my home directory: .zhistory and .zsh_history. What is the difference between them? Does Zsh keep appending lines to one of them ...
2
votes
1answer
148 views

Changing HISTTIMEFORMAT leaves entries with incorrect date

After exporting HISTTIMEFORMAT='%F %T' I tried to query history But the result shows all the commands are executed on same day. How can I check the actual date and time of actual command execution?
2
votes
3answers
53 views

How to start first command from the list printed by command 'history | grep something'

For example, I have the following output from command: loom@loom:$ history | grep MAKE 219 ../build.sh -DCMAKE_BUILD_TYPE=Debug .. 909 history | grep MAKE How to write a command, that start ...
3
votes
1answer
86 views

Root complete history commands

Where can I get root's history except besides .sh_history? I've gotten some information but only from .sh_history and the history command.
2
votes
1answer
61 views

How to get a history entry to properly display on multiple lines

Suppose I have entered a function at the bash prompt, on multiple lines rather than squeezing it onto one with semicolons: $ function blah { echo blah } $ history -1 12690 function blah {\necho ...
2
votes
2answers
177 views

Bash's declare -p HISTIGNORE brings bash to a halt! Why?

Executing the following code in GNU bash, Version 4.2.45(1)-release (x86_64-redhat-linux-gnu), Fedora 19 ... shopt -s extglob export ...
0
votes
1answer
105 views

Where does bash store the time commands were executed?

Enabling history to display time via export HISTTIMEFORMAT='%F %T ' shows the times of the commands but .bash_history doesn't contain any times. Where does bash store the times the commands were ...
3
votes
1answer
84 views

Search Alt+F2 history

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 ...
5
votes
2answers
309 views

Re-execute fc command from history

Sometimes I am using the fc builtin in bash (3.2 if that matters), to recall commands from the history. This also offers the possibility to edit, before execution. For example, by typing fc 23 27 ...
3
votes
3answers
134 views

How can I recall a numbered history command for edit?

I frequently search for changes with history | grep 'string' I get a list of commands in my history, along with the history line number), e.g. history | grep 'git' 755 git status 1535 git push ...
5
votes
2answers
189 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 ...
0
votes
1answer
489 views

datetime stamp when running history command in zsh shell

When I run the history command on my ubuntu server, I get output as follows: history ... 25 cd ~ 26 ls -a 27 vim /etc/gitconfig 28 vim ~/.gitconfig I want to view the datetime ...
3
votes
2answers
101 views

Is it possible to transfer the history of commands from one system to another?

I am going to have all my data transferred to a new PC. Is it possible to transfer the command history of the previous Linux to the new system as well? So that when I type the history command, I get ...
3
votes
0answers
156 views

How to create a bash command which creates output that exactly mimics a source text file that can be pasted into bash shell where histexpand is on?

The goal is to create a bash one line command that can be copied and pasted - for instance published on a web forum - and then patches files. See it as a way to distribute a patch file by copy and ...
0
votes
1answer
464 views

Automatically save bash command history in screen session [duplicate]

I connect to a screen session. After doing some stuff I detach it. Then in history | tail I only see screen -r and previous commands and not the commands run in screen session. Basically history shows ...
0
votes
2answers
59 views

How to find by what means a software has been installed on linux

I have plenty of softwares installed on my Linux machine (RHEL) and some were installed with yum, some other by downloading a rpm and executed it from gnome file manager. I also have few softwares ...
1
vote
3answers
81 views

Terminal: Use different command on previous file

I know that there is the !! command to reuse the previous command. How would one reuse the file or directory specified in the previous command but use a different command on it? Example: I want to ...
2
votes
2answers
692 views

HISTTIMEFORMAT modification. In /etc/bash.rc or /etc/profile? [duplicate]

I'd like to add the date/time to the output of the history command in CentOS/RHEL 6. I would like this to apply to all users on the machine by default. This itself is easy. It seems to just be a case ...
3
votes
3answers
136 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 ...
10
votes
4answers
609 views

Search for a previous command with the same prefix when I press Up at a shell prompt

Coming from a FreeBSD world I wish to make the Linux terminal behave like FreeBSD one, especially the 9.1 version, basically when you type cd in the terminal and push the "up" arrow you can browse all ...
0
votes
2answers
85 views

Why must you be careful when using Bash's built in command history function to re-run previous commands that contain variables?

I know !! re-runs commands but what exactly would occur if I re-ran a command that had a variable in the command?
2
votes
1answer
138 views

Get the last executed command line in ksh

Is there a way to get the last executed command possibly together with the arguments within a ksh script? I am using mksh with cygwin. I tried fc -nl -1, but the script throws a "“fc: history ...
14
votes
2answers
333 views

bash_history: comment out dangerous commands: `#`

To prevent logging "dangerous" commands in bash history, I have added following line to my .bashrc file: HISTIGNORE='rm *:mv *:cp *:cat*>*:pv*>*' this works well, but it has a side effect: I ...
3
votes
2answers
86 views

How to show last command with expanding function in bash

I'm using function like this. $ find-grep () { find . -type f -name "$1" -print0 | xargs -0 grep "$2" ; } After I type: $ find-grep *.c foo I want to get expanded last command string. In this ...
3
votes
1answer
141 views

What could cause my bash history to be cleared unexpectedly?

Today I noticed that my bash history is cleared completely. I have neither executed history -c nor deleted the .bash_history file. Apart from deleting the .bash_history file and history -c, how can ...