recall commands previously typed in a shell or other utility

learn more… | top users | synonyms

1
vote
1answer
18 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 ...
-1
votes
0answers
23 views

Is there any way to install grub bootloader?

I tried to install Kali Linux on Dell PC. But the Grub bootloader was not installed and because of this I can't boot Kali Linux. To overcome this problem what do I have to do?
4
votes
3answers
249 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.
33
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.
7
votes
1answer
65 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 ...
1
vote
0answers
75 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 ...
3
votes
0answers
47 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 ...
0
votes
0answers
30 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 ...
2
votes
1answer
37 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 ...
6
votes
2answers
185 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 ...
2
votes
2answers
46 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 ...
7
votes
2answers
251 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 ...
4
votes
4answers
97 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 ...
3
votes
2answers
68 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 ...
2
votes
1answer
158 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?
16
votes
8answers
2k 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 ...
3
votes
1answer
49 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 ...
1
vote
3answers
51 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
27 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 ...
2
votes
1answer
49 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 ...
15
votes
3answers
1k 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
66 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
62 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
1k 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
126 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
345 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
209 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 ...
2
votes
2answers
93 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
307 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
189 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
61 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
69 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
307 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
85 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
313 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
61 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
674 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
229 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
637 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" ...
4
votes
3answers
414 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.)
12
votes
1answer
288 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
42 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
127 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 ...
2
votes
2answers
388 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
49 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 ...
6
votes
1answer
2k 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
487 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
55 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
184 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
99 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 ...