* Re: Replace strings across all the files using script
[not found] <CAK7N6vqS7rNewOLR0aUpTHzNmOXtunwjzTu6oGM1OJ8xPWSp8g@mail.gmail.com>
@ 2014-05-16 19:56 ` Joe Perches
0 siblings, 0 replies; only message in thread
From: Joe Perches @ 2014-05-16 19:56 UTC (permalink / raw)
To: anish singh; +Cc: linux-kernel-mail
On Fri, 2014-05-16 at 12:07 -0700, anish singh wrote:
> I am planning to do some cleanup and want to
> replace some string as below across all the files
> in kernel.
> pr_err("%s "
> TO
> pr_err("%s: "
>
> Basically adding semicolon after the %s.
> How can i do it across all the files? I don't
> want to individually go to each file and do it.
Presumably, this would be done only for files that use
__func__ as the first argument to printk.
Something like this might work moderately well.
$ git ls-files | grep '\.[ch]$' | \
xargs perl -i -e 'local $/; while (<>) { s/\b(printk|pr_(?:emerg|crit|alert|err|notice|warn|warning|info))\s*\(\s*\"\%s(?:\s*\(\s*\)\s*)?(?:\s*:\s*)?\s*(?:\-\s*)?([^"]+)"\s*,(\s*)__func__\b/$1("%s: $2",$3__func__/g; print; }'
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-05-16 19:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CAK7N6vqS7rNewOLR0aUpTHzNmOXtunwjzTu6oGM1OJ8xPWSp8g@mail.gmail.com>
2014-05-16 19:56 ` Replace strings across all the files using script Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®