help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] History Expansion (J.B.)


From: Aaron Davies
Subject: Re: [Help-bash] History Expansion (J.B.)
Date: Fri, 19 Feb 2016 11:56:26 -0500

On Mon, Feb 15, 2016 at 9:08 PM, J.B. <address@hidden> wrote:

> On 01/30/2016 09:00 AM, address@hidden wrote:
>
>> I'm not too clever with history. I find that I don't use it that much, if
>> I did I'd be using zsh, not bash (they have a much more evolved history
>> setup).
>> Also, your command will not exit until you terminate it manually, that's
>> what tailf and tail do, so I'm confused as to why your expecting to read
>> multiple file in since your command entails that you intend to monitor
>> the one log file for sometime.
>> That being said, if your just looking to play with the history rreally
>> quick try UppArrow, Ctrl-w, (edit the part you want), Ctrl-y (to add the
>> stuff you killed).
>> If you want to get one line from each file and wait for more whilst
>> grep'ing those lines you could do.
>> tailf -n1 /some/really/long/path/to/a/logfile \
>> /some/other/really/long/path /and/now/a/third/path \
>> | grep -iw "some\|neat\|things\|to\|grep"
>
>
> Hi David.
>
> Currently this is what I'd do after terminating the tailf command:
> 1. Ctrl-P
> 2. Ctrl-A
> 3. Alt-F several times until I got the the end of the long file name
> 4. Ctrl-W to delete the file's absolute name
> (or Alt-D several times from the beginning of the filename)
> 5. type out the new path to the next file I want to tailf
>
> What I'd like to do instead is use history commands to quickly replace the
> long file path/name with a different one.
>
> What I've more recently tended to do is Ctrl-P, Ctrl-X Ctrl-E (or `fc -e
> vim' if $EDITOR is set to emacs or nano) and edit the command line using
> vim's efficient editing commands. But I'd really just like a way to tell
> bash, "replace that long string that matches '!?really/lon?:%' with
> 'some/other/file'." (plus, vim's filename completion is way too slow
> (^X^F)).
>
> But the closest I can get is `!:s/"type the entire file name"/"type the new
> file name"', which is a real drag.
>
> Something else that is a bit more useful is to specify the file name first
> (with a redirect), which shortens the distance the cursor has to move:
> < path/to/file tailf -n 1 [etc ....]
>
> But that assumes I don't just mindlessly bang away at the keyboard, which is
> a bad assumption. (I'd be in so much trouble if bash didn't accept
> flags/options scattered throughout the command line).
> ls /path/to/a/file -Fd /and/another/file/here -lt

what i often do with something like this is ^P, ^R, type the shortest
thing i can think of in half a second that will get me near the end of
the text i need to replace (in your example that might be " | " or
"logfile" or something), ^F (or ^B, etc.) to get out of
reverse-i-search and position the cursor exactly, ^U to kill to head,
and then re-enter the short initial command ("tailf -n1 ") and the
long filename

another way to restructure your command to make the path easier to
replace could be to use process substitution to force it to the *end*
of the line, making the replace sequence "^P^R<space>^K<space><new
filename>)":

grep -iw "some\|neat\|things\|to\|grep" <(tailf -n1
/some/really/long/path/to/a/logfile)
-- 
Aaron Davies
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]