Article View: comp.sources.d
Article #5050Re: Column shifting
From: T. William Wells
Date: Sun, 28 May 1989 00:10
Date: Sun, 28 May 1989 00:10
32 lines
1552 bytes
1552 bytes
In article <4310004@hpcvca.CV.HP.COM> charles@hpcvca.CV.HP.COM (Charles Brown) writes:
: > I'm wondering if there's been a program written that takes a file and
: > outputs that same file except with arbitrary columns shifted over.
: > Some examples are:
: >
: > input file is: 0123456789
: >
: > Move column 7 to column 1: 0712345689
:
: Try:
: sed -e "s/^\(.\)\(.....\)\(.\)/\1\3\2/"
Watch out for this: regular expressions for sed containing long
strings of `.'s seem to be able to overflow internal buffers or
something and sed doesn't tell you that it has failed. I've seen this
happen on SunOS (3.2, I think) and on SysV/386 3.0.
I've also seen this happen with egrep.
(No, I don't have specifics; each time this has happened, I've been
too busy to nail down the problem.)
One other option is to use cut(1) and paste(1).
Some people might suggest awk, but if efficiency is a concern, skip
it. Awk, at least as provided as a command with the UNIXs I've used,
is amazing inefficient.
(And all of this assumes UNIX. Let's hope we're right.)
---
Bill { uunet | novavax } !twwells!bill
Technical Details
Message-ID:
<1001@twwells.uucp>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!novavax!twwells!billReferences:
<68500002@sts> <4310004@hpcvca.CV.HP.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!novavax!twwells!bill From: bill@twwells.uucp (T. William Wells) Newsgroups: comp.sources.d Subject: Re: Column shifting Message-ID: <1001@twwells.uucp> Date: 28 May 89 00:10:43 GMT References: <68500002@sts> <4310004@hpcvca.CV.HP.COM> Reply-To: bill@twwells.UUCP (T. William Wells) Organization: None, Ft. Lauderdale Lines: 32