From: Joe Perches <joe@perches.com>
To: anish singh <anish198519851985@gmail.com>
Cc: linux-kernel-mail <linux-kernel@vger.kernel.org>
Subject: Re: Replace strings across all the files using script
Date: Fri, 16 May 2014 12:56:31 -0700 [thread overview]
Message-ID: <1400270191.12373.12.camel@joe-AO725> (raw)
In-Reply-To: <CAK7N6vqS7rNewOLR0aUpTHzNmOXtunwjzTu6oGM1OJ8xPWSp8g@mail.gmail.com>
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; }'
parent reply other threads:[~2014-05-16 19:56 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <CAK7N6vqS7rNewOLR0aUpTHzNmOXtunwjzTu6oGM1OJ8xPWSp8g@mail.gmail.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1400270191.12373.12.camel@joe-AO725 \
--to=joe@perches.com \
--cc=anish198519851985@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®