Search Results

Search: Posts Made By: kikionline
10,781
Posted By binlib
So much interest in this topic, let's try another...
So much interest in this topic, let's try another way for performance since his file is huge. This will edit the file in place and should be blazing fast.

linux$ cat t.c
#include <stdlib.h>...
10,781
Posted By Scrutinizer
Alternatively: awk '/^[THD]/{print...
Alternatively:
awk '/^[THD]/{print p;p=$0;next}{p=p FS $0}END{print p}' infile
or
awk '/^[THD]/{print RS}1' ORS= infile
10,781
Posted By ctsgnb
you can give a try with this awk...
you can give a try with this
awk '{n="\n"}/^HEADER/{print;delete A[D];next}/^D/{p=(!A[D]++)?z:n;printf p $0;next}{y=(/^TRAILER/)?n:z;printf y $0 y}' tst
10,781
Posted By mirni
Awk solution: awk ' NR==1{print} ...
Awk solution:

awk '
NR==1{print}
/^TRAILER/{if(a) print a; print ; exit}
NR>1 && !/^D/{print a" "$0; a=""}
/^D/{ if(a) print a; a=$0 }' infile
10,781
Posted By archimedes
Hi... a solution using awk awk '{ if(NR == 1)...
Hi... a solution using awk
awk '{
if(NR == 1)
print $0;
else if(NR != 1)
{
if($0 !~ /^TRAILER/)
{
if($0 ~ /^D/)
{
printf "%s\n", $0 ; next
}
else
{
}
}
else
{
last=$0;
}
10,781
Posted By birei
Here you have a perl script, I hope it works now ...
Here you have a perl script, I hope it works now

$ cat infile
HEADER474687
D1356jkl ugbliuybikb 879870
898976098 9687680
D77656757 uhgliug liygoiygig
D98679hjh kjbgihguygfu ugliyh...
Showing results 1 to 6 of 6

 
All times are GMT -4. The time now is 01:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy