Re: [opensuse] Another grep question



Jim:

How about a Perl solution?

I'm sure a Perl Guru could do it in one line but it works on a file
created on a Linux box.

If the original data was created on a Windoze box you may need to deal
with other end of line issues. Also, if there are stray spaces laying
around that may cause grief -

Hope it works!

No warranty - implicit or implied!


Michael

concat4lines.pl
=================================
#!/usr/bin/perl -w
#
# Author: Michael W Folsom
#
# April 8, 2007
#
# USAGE: ./concat4lines.pl input_file_name
#
#

open(FILE, $ARGV[0]);

$NewStr ="";
$i = 0;

while (<FILE>) {
# assign the contents of the current line in the file
# to the built in variable $_
chomp($_);

if($i < 4) {
#print $_;
$NewStr = $NewStr . $_;
$i++;
if($i < 4) {
#print "\t";
$NewStr = $NewStr . "\t";
}
else {
print "$NewStr \n";
#$NewStr = $NewStr . "\n";
$i= 0;
$NewStr = "";
}
}
}

# if number of lines not equal to 4 then print out left overs
if($NewStr) {
print "$NewStr\n";
}

close(FILE);

exit();
=====================================================

On 4/8/07, James Hatridge <James.Hatridge@xxxxxx> wrote:
Hi all,,

I'm not sure if this is a grep or awk question. I have a file with many
records of 4 lines each in it. Like this:

1
2
3
4
1
2
3
4
etc, etc

I need the file to look like this:

1 tab 2 tab 3 tab 4
1 tab 2 tab 3 tab 4
etc etc....

How can I do this?

Thanks,

JIM
--
Jim Hatridge
Linux User #88484
Ebay ID: WartHogBulletin
------------------------------------------------------
WartHog Bulletin
Info about new German Stamps
http://www.WartHogBulletin.de

Many Enemies -- Much Honor!
Anti-US Propaganda stamp collection
http://www.manyenemies-muchhonor.info

An American in Bavaria
http://www.gaubodengalerie.de
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx


--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx



Relevant Pages

  • Re: [opensuse] Why are there not more using Linux?
    ... Network Engineer ... But Suns and SPARCs are yesterday dude:) Linux and x86-64 are NOW! ... To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx ... For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx ...
    (SuSE)
  • Re: [opensuse] More 10.2 nightmares
    ... To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx ... For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx ... I have learned quite a lot about linux since ... linux, and all the girls use macs, so it's an all-unix house, and virus free! ...
    (SuSE)
  • Re: [opensuse] More 10.2 nightmares
    ... To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx ... For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx ... about linux since then and am willing to try anything. ... It's like console game companies, w/ the exception that game makers ...
    (SuSE)
  • Re: [opensuse] Installation methods
    ... UNIX since 1989, linux since 1994, SuSE since 1998 ... To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx ... For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx ...
    (SuSE)
  • Re: New IP based security hole in Windows 2000 (yet again)
    ... First you see the boot loader - GRUB which is not Linux. ... used to load any thing, including windoze, *nix, *BSD - you name it. ... But the commands I'm using? ... the compiling) and 'make install' which installs the executables. ...
    (alt.computer.security)