On 14/09/12 20:38, sc wrote:
> On Fri, Sep 14, 2012 at 01:14:58PM -0500, sc wrote:
>> On Fri, Sep 14, 2012 at 01:11:45PM -0500, sc wrote:
>>> On Fri, Sep 14, 2012 at 12:46:08PM -0500, Tim Chase wrote:
>>>> On 09/14/12 12:10, Ben Fritz wrote:
>>>>> On Friday, September 14, 2012 12:06:41 PM UTC-5, sc wrote:
>>>>>> On Fri, Sep 14, 2012 at 12:14:41PM -0400, ping wrote:
>>>>>>> assume I have a tar ball containing muliple files and I don't want
>>>>>>> to uncompress everything in a folder to start my search (since vim
>>>>>>> can open compressed/tar.ed files on the fly), is there way to search
>>>>>>> a keyword through all the files in the tarball?
>>>>>>
>>>>>> do you have zgrep available? if so you can
>>>>>> zgrep 'pattern' tar-gz-file | vim -
>>>>>
>>>>> I didn't know about zgrep! But how about setting 'grepprg' to use
>>>>> it rather than grep? Then you can navigate results easier.
>
>>>> Does it work for you with gzipped tar files? I know you can use
>>>> zgrep for plain (non-tar'ed) gzipped files, but when I try it on a
>>>> gzipped tar file, it only tells me that a binary file matches:
>
>>>> ~$ cd tmp
>>>> ~/tmp$ mkdir d
>>>> ~/tmp$ cd d
>>>> ~/tmp/d$ echo alpha > a.txt
>>>> ~/tmp/d$ echo beta > b.txt
>>>> ~/tmp/d$ echo delta > d.txt
>>>> ~/tmp/d$ cd ..
>>>> ~/tmp$ tar cvfz d.tgz d/
>>>> d/
>>>> d/a.txt
>>>> d/d.txt
>>>> d/b.txt
>>>> ~/tmp$ zgrep alpha d.tgz
>>>> Binary file (standard input) matches
>
>>> to be honest I don't know -- I learned about zgrep quite recently and
>>> have never had occasion to use it -- I only briefly scanned the man
>>> page before posting -- forgive me, I assumed it would handle tarfiles
>>> too
>
>>> maybe you'd need something like
>
>>> tar -xz tar-gz-file | grep 'pattern'
>
>> and let me add an O:
>
>> tar -xzO tar-gz-file | grep 'pattern'
>
>> that should do it
>
> no, but
>
> tar -zxOf targzfile
>
> will send it to stdout, but grep just reports the binary file matches
>
> so to use vim and search you could
>
> tar -zxOf targzfile | vim -
>
> and then search the buffer for your pattern
>
> sc
>
You would still have all files concatenated, which might be a little
unwieldy if there are many of them. Maybe untar them to disk (into some
empty ad-hoc directory if the archive doesn't create a top-level
directory), then use the :vimgrep command (q.v.)?
mkdir foobar
tar -zxvC foobar -f rah-rah-blah-604.3.2.en-US.linux-x86_64.tar.gz
gvim
:0verbose vimgrep /pattern/ foobar/**
:cnext
...
(The same works for a .tar.bz2, but with -j instead of -z)
The following mappings may come handy with any quickfix commands:
map <F2> :cnext<CR>
map <S-F2> :cprev<CR>
map <F3> :cnfile<CR>
map <S-F3> :cpfile<CR>
map <F4> :clast<CR>
map <S-F4> :cfirst<CR>
Best regards,
Tony.
--
Have you noticed the way people's intelligence capabilities decline
sharply the minute they start waving guns around?
-- Dr. Who
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment