Home > Archive > AWK > December 2004 > Line break trouble
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Line break trouble
|
|
| BlackSun 2004-12-03, 3:56 pm |
| Hello Folks,
I am totally newbie on AWK programming and I need to use this tool for
a windows text file conversion in a DOS batch file.
I need to break the line every time the ";" symbol appears. As the
follow example:
Normal text:
"ForegroundApplicationBoost"="2";"BootDevice"=" \\Device\\HarddiskDmVolumes\\Ft3300Dg0\\
Volume1";"BuildNumber"="3790";"FreeSpaceInPagingFiles"="3672612";"CSName"="FT3300";"Caption"="Microsoft(R)
Windows(R) Server 2003, Enterprise Edition";"CodeSet"="1252";
Text after AWK
ForegroundApplicationBoost"="2";
"BootDevice"=" \\Device\\HarddiskDmVolumes\\Ft3300Dg0\\
Volume1";
"BuildNumber"="3790";
"FreeSpaceInPagingFiles"="3672612";
"CSName"="FT3300"
"Caption"="Microsoft(R) Windows(R) Server 2003, Enterprise Edition";
"CodeSet"="1252";
I need to create a new text file after the conversion without modify
the original source. Is it possible? (Normal file > AWK > New file
with break lines).
How do I program this??
Thank a lot!
Andre
| |
| Koriolan 2004-12-03, 3:56 pm |
| BlackSun napisaĆ(a):
> I need to break the line every time the ";" symbol appears. As the
> follow example:
>
> Normal text:
> "ForegroundApplicationBoost"="2";"BootDevice"=" \\Device\\HarddiskDmVolumes\\Ft3300Dg0\\
Volume1";"BuildNumber"="3790";"FreeSpaceInPagingFiles"="3672612";"CSName"="FT3300";"Caption"="Microsoft(R)
> Windows(R) Server 2003, Enterprise Edition";"CodeSet"="1252";
>
> Text after AWK
> ForegroundApplicationBoost"="2";
> "BootDevice"=" \\Device\\HarddiskDmVolumes\\Ft3300Dg0\\
Volume1";
> "BuildNumber"="3790";
> "FreeSpaceInPagingFiles"="3672612";
> "CSName"="FT3300"
> "Caption"="Microsoft(R) Windows(R) Server 2003, Enterprise Edition";
> "CodeSet"="1252";
>
awk '{ gsub(/;/, ";\x0D\x0A" ); print}'
np.[color=darkred]
echo " ala;ola;lola;ela;" | awk '{ gsub(/;/, ";\x0D\x0A" ); print}'
ala;
ola;
lola;
ela;
Problem is ... echo " ola; lola ; 'it;is;one;string'; ala "
.....
it;
is;
....
Koriolan
| |
| Ed Morton 2004-12-03, 3:56 pm |
|
BlackSun wrote:
<snip>
> I need to break the line every time the ";" symbol appears. As the
> follow example:
>
> Normal text:
> "ForegroundApplicationBoost"="2";"BootDevice"=" \\Device\\HarddiskDmVolumes\\Ft3300Dg0\\
Volume1";"BuildNumber"="3790";"FreeSpaceInPagingFiles"="3672612";"CSName"="FT3300";"Caption"="Microsoft(R)
> Windows(R) Server 2003, Enterprise Edition";"CodeSet"="1252";
>
> Text after AWK
> ForegroundApplicationBoost"="2";
> "BootDevice"=" \\Device\\HarddiskDmVolumes\\Ft3300Dg0\\
Volume1";
> "BuildNumber"="3790";
> "FreeSpaceInPagingFiles"="3672612";
> "CSName"="FT3300"
> "Caption"="Microsoft(R) Windows(R) Server 2003, Enterprise Edition";
> "CodeSet"="1252";
>
> I need to create a new text file after the conversion without modify
> the original source.
awk does not modify the original source unless you write specific code
to make that happen.
Is it possible? (Normal file > AWK > New file
> with break lines).
>
> How do I program this??
gawk -vRS=";" -vORS=";\n" '1' infile > outfile
e.g.:
PS1> printf "a;b;c;" | gawk -vRS=";" -vORS=";\n" '1'
a;
b;
c;
You will have to deal with newlines or linefeeds if present in your
input file and you don't want them in the output file.
Ed.
| |
| William James 2004-12-03, 8:55 pm |
| BEGIN { FS=";"
OFS=";\n"
ORS=""
}
{ $1=$1; print }
| |
| Ed Morton 2004-12-07, 3:59 am |
|
BlackSun wrote:
<snip>
> I need to break the line every time the ";" symbol appears. As the
> follow example:
>
> Normal text:
> "ForegroundApplicationBoost"="2";"BootDevice"=" \\Device\\HarddiskDmVolumes\\Ft3300Dg0\\
Volume1";"BuildNumber"="3790";"FreeSpaceInPagingFiles"="3672612";"CSName"="FT3300";"Caption"="Microsoft(R)
> Windows(R) Server 2003, Enterprise Edition";"CodeSet"="1252";
>
> Text after AWK
> ForegroundApplicationBoost"="2";
> "BootDevice"=" \\Device\\HarddiskDmVolumes\\Ft3300Dg0\\
Volume1";
> "BuildNumber"="3790";
> "FreeSpaceInPagingFiles"="3672612";
> "CSName"="FT3300"
> "Caption"="Microsoft(R) Windows(R) Server 2003, Enterprise Edition";
> "CodeSet"="1252";
>
> I need to create a new text file after the conversion without modify
> the original source.
awk does not modify the original source unless you write specific code
to make that happen.
Is it possible? (Normal file > AWK > New file
> with break lines).
>
> How do I program this??
gawk -vRS=";" -vORS=";\n" '1' infile > outfile
e.g.:
PS1> printf "a;b;c;" | gawk -vRS=";" -vORS=";\n" '1'
a;
b;
c;
You will have to deal with newlines or linefeeds if present in your
input file and you don't want them in the output file.
Ed.
|
|
|
|
|