Denny’s OpenBSD Newbies blog

April 16, 2010

Partitioning Trick Update

I added some information on some of the new stuff in the OpenBSD
disklabel(8) portion of the installation process on my page at:

Partitioning Trick

There’s a link there, too, to a good write-up on preserving your disk layout:

Preserving an existing OpenBSD partition layout during a re-install

Also picked up on a good way today to rename multiple files using perl:

ls -1 | perl -nle’$o=$_; s/OLDPATTERN/NEWPATTERN/; $n=$_; rename($o,$n)if!-e$n’

Pretty nifty. You can rename any part of the file names.

Cheers

4 Comments »

  1. when ls is outputting to something that isn’t a terminal (like a pipe) it defaults to -1 so the switch is redundant. Interesting and potentially useful.

    Comment by Andrew Fresh — April 20, 2010 @ 7:39 am

  2. You’re absolutely correct. I guess whoever put that together to begin with,
    and I can’t recall where I read it when I was trying to figure out how to do
    it all in one line, figured it was just a good habit. But you’re right. In this
    particular instance, with the output being piped as it is, the 1 is redundant.

    Comment by denny — April 20, 2010 @ 6:26 pm

  3. [...] This post was mentioned on Twitter by Denny White. Denny White said: OpenBSD Partitioning Trick Update: Denny's OpenBSD Newbies blog: http://bit.ly/cjSfVQ [...]

    Pingback by Tweets that mention Partitioning Trick Update « Denny’s OpenBSD Newbies blog -- Topsy.com — April 28, 2010 @ 2:48 pm

  4. Here’s a way to do it recursively:

    perl -MFile::Find -e ‘find(sub {if (-f and /oldpattern/) \
    { $old = $_; s/oldpattern/newpattern/g; rename $old, $_}}, “.”)’

    Comment by denny — April 30, 2010 @ 12:11 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress

Rss Feed Tweeter button Facebook button Technorati button Reddit button Myspace button Linkedin button Webonews button Delicious button Digg button Stumbleupon button Newsvine button Youtube button