Thursday, February 28, 2013

Re: Search Patterns




John Lusby <jlusby42@gmail.com> a écrit :
That worked almost perfectly. The only problem with this one is that the files that are in the working directory aren't proceeded by a slash. I gather that the pattern you gave is for ^ followed by any number of non / characters. I guess I got confused and thought that * was itself a wild card. 

Thank you very much Christian. I've figured out what I needed and more. With your start and a bit of googling the right answer ended up being :%s/^\S*\s//. Another source of confusion had been that I didn't realize >> was append so I was sometimes opening files and not realizing I was seeing outputs from different versions of my command. The proper output from just the grep with no modification was just

[01;31m [Kpreprocessing [m [K /home/john/local/tinyos-2.x/tos/chips/msp430/McuSleepC.nc
[01;31m [Kpreprocessing [m [K /home/john/local/tinyos-2.x/tos/interfaces/McuPowerState.nc
[01;31m [Kpreprocessing [m [K /home/john/local/tinyos-2.x/tos/interfaces/McuPowerOverride.nc
[01;31m [Kpreprocessing [m [K gridEyeAppC.nc
[01;31m [Kpreprocessing [m [K /home/john/local/tinyos-2.x/tos/system/MainC.nc
[01;31m [Kpreprocessing [m [K /home/john/local/tinyos-2.x/tos/interfaces/Boot.nc
[01;31m [Kpreprocessing [m [K /home/john/local/tinyos-2.x/tos/interfaces/Init.nc

The pattern you gave me worked great for every pattern except the ones in the current directory because they didnt have a /, but thats my fault because I linked a portion of the list that didn't include that. Thank you again

-John


On Wed, Feb 27, 2013 at 12:08 AM, Christian Brabandt <cblists@256bit.org> wrote:
On Wed, February 27, 2013 06:37, John Lusby wrote:
> Hello,
>
> I'm currently trying to read a list of files from a make output and push
> them into ctags but I'm having trouble with the substitute. I've been
> using
> vim to try to get the pattern right but I cant seem to figure it out.
>
> I'm currently at the point where my command looks like
>
> make telosb verbose 2>&1 >/dev/null | grep 'preprocessing' | sed -e
> 's/preprocessing//' -e 's/ //' >>somefilenames2.txt
>
> but the lines in somefilenames look all garbled
>
> Heres a snippet
>
> [01;31m [K [m [K/usr/lib/ncc/deputy_nodeputy.h
>  [01;31m [K [m [K/usr/lib/ncc/nesc_nx.h
> [01;31m [K [m [K/home/john/local/tinyos-2.x/tos/system/tos.h
> [01;31m [K [m [K/home/john/local/tinyos-2.x/tos/system/TinySchedulerC.nc
> [01;31m [K [m [K/home/john/local/tinyos-2.x/tos/interfaces/Scheduler.nc
>
> I tried using a pattern like :%s/^*\/// to replace it but that just said
> no
> pattern ^*\/ found. Does anyone know what I'm doing wrong?
>
> Thanks for the help,

Looks like your make program outputs terminal sequences to e.g. display
colors? Try explicitly setting your terminal to somthing dumb for make.
It shouldn't then output those chars:
TERM=vt100 make ...

Your pattern doesn't look right btw. I think what you want to search for
is :%s/^[^/]*//

Your pattern ^*\/ is actually looking for line start followed by a '*'
followed by a slash, which is obviously not what you need.

regards,
Christian

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


As Christian suggested, removing the colors escaped sequences from the source may be simplier. For grep, just append \ : cmd | \grep pattern > file

--
Envoyé de mon téléphone Android avec K-9 Mail. Excusez la brièveté.

No comments:

Post a Comment