Tech Support > Computers & Technology > If line 7 NEQ B, insert newline - how?
If line 7 NEQ B, insert newline - how?
Posted by John Bartley K7AAY on March 10th, 2008


I have beat my head against numerous FAQs and pages of examples today,
and therefore ask for the kind and beneficent help of the assembled
multitude herein.

I need to check the 7th line of a short (15 lines) text file.
If the 1st character is not a B insert a newline

I have tried numerous variations on
sed 7,1 and am getting nowhere.

If you can help me, please do.

Thank you.

Posted by Mike Easter on March 10th, 2008


John Bartley K7AAY wrote:
User-Agent: G2/1.0
Windows; Firefox/2.0.0.12,

You are a GGer driving a Win Ff browser. Is this a homework assignment?

You need to do that with a what?

Sed Stream Editor is a /n/x app and programming language which has been
ported to Win and others.

The wiki has a good general entry on sed and its scripts, and has a
collection of reference links many of which have collections of more
links and scripts:

http://en.wikipedia.org/wiki/Sed sed (Stream EDitor) refers to a Unix
utility for parsing text files and the programming language it uses - is
available today on most operating systems.

External links
Major sources for sed scripts, files, usage
Handy one-line sed scripts
Sed script archive
A home page for sed, some focus on Windows/DOS
Paper describing Turing machine in sed, and its universality
Turing machine in sed, the actual script
A calculator written in sed
Super-sed
sed Sokoban
sed Tutorial
The sed tutorial from Grymoire
GNU utilities for Win32
More on the address command and sub-matched replacements
Minised homepage
PCRE - Perl Compatible Regular Expressions

--
Mike Easter


Posted by John Bartley K7AAY on March 10th, 2008


On Mar 10, 12:17 pm, "Mike Easter" <Mi...@ster.invalid> wrote:
No, a gen-u-wine work task.
That's right. The GNUWIN32 version is just dandy for many other
similar tasks, and this suggestion from a kinf gent in Germany solved
the problem...

sed "7 s/^[^B].*/\n&/"


Which I had pored over extensively before posting.

Posted by Mike Easter on March 10th, 2008


John Bartley K7AAY wrote:

Thanks for the feedback.



--
Mike Easter

Posted by chuckcar on March 10th, 2008


John Bartley K7AAY <john.bartley@gmail.com> wrote in
news:16285a87-696f-4eea-8cc8-34581cec0ed8@i29g2000prf.googlegroups.com:

Sounds like about a 15 line c program to me.

--
(setq (chuck nil) car(chuck) )

Posted by Pennywise@DerryMaine.Gov on March 11th, 2008


John Bartley K7AAY <john.bartley@gmail.com> wrote:

Fairly easy in UltraEdit
--

Give free rice to hungry people by playing a simple word game.
http://freerice.com/index.php?cool
The real loser: the one who has to count the grains of rice.


Similar Posts