hi all i have sample and i need script to do this
/dev/xxx oracle test
/dev/sap
9999 000 88 99
i need the out put like this
/dev/xxx oracle test
/dev/sap 9999 000 88 99
can any one provide me with an idea to solve this problem
hi all i have sample and i need script to do this
/dev/xxx oracle test
/dev/sap
9999 000 88 99
i need the out put like this
/dev/xxx oracle test
/dev/sap 9999 000 88 99
can any one provide me with an idea to solve this problem
awk '{printf (NR-1 && (/^\//)?RS:X) $0}' infile
sed '2{N;s/\n/ /;}'
Another one,
awk ' _s { print _s,$0; _s="";next; }NF==1 { _s=$0; }!_s' < file
Dear Friend,
You can use the following code
use strict;
use warnings;
my ($var,$var1);
open (FH,"<file");
while($var=<FH>)
{
chomp($var);
if($var=~/\/dev\/sap/)
{
$var1=<FH>;
$var=$var. " $var1";
}
print "$var\n";
}
alister your solution will work only for the first occurrence.
dennis.jacob your solution will work only on next line.
Try on this data sample:
/dev/xxx oracle test
/dev/sap
9999 000 88 99
/dev/xxx oracle test
/dev/sap
9999 000 88 99
9999 000 88 99
danmero, I did not get you. I think the output which I am getting for the sample data is correct as per my understanding.
/home/usr1 >awk ' _s { print _s,$0; _s="";next; }NF==1 { _s=$0; }!_s' < file
/dev/xxx oracle test
/dev/sap 9999 000 88 99
/dev/xxx oracle test
/dev/sap 9999 000 88 99
9999 000 88 99
/home/usr1 >cat file
/dev/xxx oracle test
/dev/sap
9999 000 88 99
/dev/xxx oracle test
/dev/sap
9999 000 88 99
9999 000 88 99
Hi, danmero:
You are correct. It works just as I intended. I see nothing in the original post suggesting that anything more is required, but kudos to you for going above and beyond.
Regards,
Alister
Cheers danmero, I didn't understand your script until I debug it.