help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Help-bash Digest, Vol 52, Issue 7


From: J.B.
Subject: Re: [Help-bash] Help-bash Digest, Vol 52, Issue 7
Date: Fri, 18 Mar 2016 10:50:48 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

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
Perhaps someone else knows what bash means by "Event specification" with
respect to the section on "Word designators" in bash's man page. I can't
figure it out for the life of me.

I though of another way that's shorter then ^Fa^Fb^.
export file="/some/long/path/to/file.txt"
tailf $file
export file="/new/long/path/to/file.txt"

Alternatively, if the file names remain the same across runs they can be
permanent variables.

Sincerely, David

I think 'event specification' refers to the event designator minus the arguments, ie, it's synonymous with 'event designator'- "A : separates the event specification from the word designator."

`echo foo bar doo'
`!:2' -- '2' is the word designator; '!' is the event designator or event specifier.

I like your idea of assigning the filename to a variable, too.

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

I think that's probably close to what I'll more often do: I'll type out my command 
line and pipes, then Ctrl-A, </path/to/file.
And to edit the log file's name, I'll just Ctrl-A, Alt-D to erase the entire 
file.

Thank you both for your suggestions.



reply via email to

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