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 I can see what has been. Now I also want to see what's going on so I need to exchange cat with tail -f giving me this:

tail -f /path/to/logfile | grep -iEw 'some-ip-address-here|correspondig-mac-adress-here'
  • 2
    Probably none that are shorter than up-arrow, home key, 3*delete and type tail -f. – Julie Pelletier Jun 22 '16 at 7:35
  • home key does not work home key inserts a ~ maybe thats something i have change myself but i got used to it and don't wana miss it also in putty home button inserts a ~ and pressing 30 to 40 times left-arrow is definitly not short – konqui Jun 22 '16 at 8:02
  • 1
    Try CTRL-a instead of home key. – Michael Vehrs Jun 22 '16 at 8:49

You can use !!:* to refer to all the words but the zeroth of the last command line.

!! refers to the previous command, : separates the event specification from the word designator, * refers to all the words but the zeroth.

This is from the HISTORY EXPANSION section of bash(1).

wieland@host in ~» cat foo | grep bar
wieland@host in ~» tail -f !!:*
tail -f foo | grep bar

You could also use quick substitution where ^string1^string2^ repeats the last command, replacing string1 with string2:

wieland@host in ~» cat foo | grep bar
wieland@host in ~» ^cat^tail -f
tail -f foo | grep bar
  • what i use now is cat to tail !!:* and tail to cat !!:2-$ – konqui Jun 22 '16 at 10:08
  1. Press Up or Ctrl+P to recall the previous line. Repeat if you want the line before, etc.
  2. Press Home or Ctrl+A to go to the beginning of the line.
  3. Press Alt+D to delete the word under the cursor, i.e. the command you want to replace.
  4. Type the command you want to run now.
  5. Press Enter to run the command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.