9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Martin Harriss <martin@Princeton.EDU>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] simple question: multiple rename
Date: Fri,  5 Jun 2009 16:04:17 -0400	[thread overview]
Message-ID: <4A297A41.2070803@Princeton.EDU> (raw)
In-Reply-To: <a560a5d00906051258v68665394mf9b0a5786468b30e@mail.gmail.com>

Rudolf Sykora wrote:
> Hello,
>
> I realized I cannot come up with a simple solution for the following.
> I want to rename all the files whose names end with _g_b to just _g,
> e.g. hello_g_b should be renamed to hello_g.
> I simply don't know an easy way.
> [the opposite way is simple: for(i in *_g) mv $i $i^_b ]
> I only think about so complicated ways like
>
> for(i in *_g_b) {
>     s = `{sam -d <<EOF <{echo $i} >[2] /dev/null
>         1s/(.+)_g/\1
>         p
>         EOF
>         }
>     mv $i $s
> }
>
> which describes my idea, but doesn't work, actually. (btw. how can one
> correct it?)
>
> Thanks
> Ruda
>

sed is your friend:

s=`{ echo $i | sed -e 's/_g_b/_g/' }


Martin




  reply	other threads:[~2009-06-05 20:04 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-05 19:58 Rudolf Sykora
2009-06-05 20:04 ` Martin Harriss [this message]
2009-06-05 20:07   ` Rudolf Sykora
2009-06-08  7:50 ` Rudolf Sykora
2009-06-08  9:35   ` Russ Cox
2009-06-16 11:51     ` roger peppe
2009-06-16 12:00       ` erik quanstrom
2009-06-16 12:43         ` Ethan Grammatikidis
2009-06-16 12:52           ` erik quanstrom
2009-06-16 14:07             ` Russ Cox
2009-06-16 14:40               ` erik quanstrom
2009-06-16 23:00             ` Ethan Grammatikidis
2009-06-16 23:01               ` erik quanstrom
2009-06-17 14:34                 ` Ethan Grammatikidis
2009-06-18 22:54                 ` John Floren
2009-06-18 22:59                   ` erik quanstrom
2009-06-16 15:48           ` Charles Forsyth
2009-06-16 15:31             ` erik quanstrom
2009-06-16 22:57               ` Ethan Grammatikidis
2009-06-16 15:55           ` john
2009-06-16 17:19             ` Tim Newsham
2009-06-16 23:05             ` Ethan Grammatikidis
2009-06-08  9:45   ` Martin Neubauer
2009-06-08 10:40     ` Rudolf Sykora
2009-06-16 18:34 Francisco J Ballesteros

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=4A297A41.2070803@Princeton.EDU \
    --to=martin@princeton.edu \
    --cc=9fans@9fans.net \
    /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;
as well as URLs for NNTP newsgroup(s).