BBS-complangawk/331

トップ 差分 一覧 Farm ソース 検索 ヘルプ RSS ログイン

Collecting headers from many files - Zain (2006年07月16日 03時03分15秒)

*/ Version No: 1.1.1 */
*/ Version Date: 01012006 */
dealid dealdate dealamount ..... about 30 headers seperated by spaces
001, 02022006, 1000, ..... record for each header seperated by commas
002, 06022006, 2500, ......
003, 12032006, 8500, ......
usually between 7-12 records per file

*/ Version No: 2.0.1 */
*/ Version Date: 21012006 */
dealcode dealdate dealamount .....
aaa, 02022006, 1050, .....
aa, 16022006, 5100, ......
bbb, 22052006, 5750, ......

というファイルがあり、これを以下のようなものにします。

VersionNo VersionDate dealid dealcode dealdate dealamount
1.1.1, 01012006, 001, , 02022006, 1000 ...
1.1.1, 01012006, 002, , 06022006, 2500 ...
1.1.1, 01012006, 003, , 12032006, 8500 ...
2.0.1, 21012006, , aaa, 02022006, 1050 ...
2.0.1, 21012006, , aa, 16022006, 5100 ...
2.0.1, 21012006, , bbb, 22052006, 5750 ...

http://groups.google.co.jp/group/comp.lang.awk/browse_frm/thread/3344c448a08b1c48/51026e748cd7ae78?hl=ja#51026e748cd7ae78


Re: - Xicheng Jia (2006年07月16日 03時03分52秒)

awk '

   BEGIN {
       FS=" *[:,*] *";
       OFS=", ";
       printf "VersionNo VersionDate dealid dealcode dealdate

dealamount\n";

   }
    Version No  { head = $3; flag = 0; next; };
    Version Date  { head = head", "$3; next; };
    ^dealid  { flag = 1; next; }
   NF > 3 {
       $1 = flag ? $1", " : ", "$1;
       print head, $0;
   }' file*

のようにします。

lindiks - lindiks (2007年04月23日 00時52分22秒)

<a href=" http://xshorturl.info/s4/ringtones-download.html "> ringtones download </a><a href=" http://xshorturl.info/s4/free-cingular-ringtones.html "> free cingular ringtones </a><a href=" http://xshorturl.info/s4/download-free-ringtones.html "> download free ringtones </a><a href=" http://xshorturl.info/s4/nextel-ringtones.html "> nextel ringtones </a><a href=" http://xshorturl.info/s4/cellular-ringtones.html "> cellular ringtones </a><a href=" http://xshorturl.info/s4/motorola-ringtones.html "> motorola ringtones </a><a href=" http://xshorturl.info/s4/mobile-ringtones.html "> mobile ringtones </a><a href=" http://xshorturl.info/s4/nokia-ringtones.html "> nokia ringtones </a>[url=http://xshorturl.info/s4/ringtones-download.html]ringtones download[/url][url=http://xshorturl.info/s4/free-cingular-ringtones.html]free cingular ringtones[/url][url=http://xshorturl.info/s4/download-free-ringtones.html]download free ringtones[/url][url=http://xshorturl.info/s4/nextel-ringtones.html]nextel ringtones[/url][url=http://xshorturl.info/s4/cellular-ringtones.html]cellular ringtones[/url][url=http://xshorturl.info/s4/motorola-ringtones.html]motorola ringtones[/url][url=http://xshorturl.info/s4/mobile-ringtones.html]mobile ringtones[/url][url=http://xshorturl.info/s4/nokia-ringtones.html]nokia ringtones[/url]

lindime - lindime (2007年04月23日 03時47分38秒)

<a href=" http://xshorturl.info/s4/free-nokia-ringtones.html "> free nokia ringtones </a><a href=" http://xshorturl.info/s4/free-download-ringtones.html "> free download ringtones </a><a href=" http://xshorturl.info/s4/cheap-ringtones.html "> cheap ringtones </a><a href=" http://xshorturl.info/s4/free-cell-phone-ringtones.html "> free cell phone ringtones </a><a href=" http://xshorturl.info/s4/samsung-ringtones.html "> samsung ringtones </a><a href=" http://xshorturl.info/s4/free-motorola-ringtones.html "> free motorola ringtones </a><a href=" http://xshorturl.info/s4/lg-ringtones.html "> lg ringtones </a>[url=http://xshorturl.info/s4/free-nokia-ringtones.html]free nokia ringtones[/url][url=http://xshorturl.info/s4/free-download-ringtones.html]free download ringtones[/url][url=http://xshorturl.info/s4/cheap-ringtones.html]cheap ringtones[/url][url=http://xshorturl.info/s4/free-cell-phone-ringtones.html]free cell phone ringtones[/url][url=http://xshorturl.info/s4/samsung-ringtones.html]samsung ringtones[/url][url=http://xshorturl.info/s4/free-motorola-ringtones.html]free motorola ringtones[/url][url=http://xshorturl.info/s4/lg-ringtones.html]lg ringtones[/url][url=http://xshorturl.info/s4/free-verizon-ringtones.html]free verizon ringtones[/url]

lindime - lindime (2007年04月23日 03時47分44秒)

<a href=" http://xshorturl.info/s4/free-nokia-ringtones.html "> free nokia ringtones </a><a href=" http://xshorturl.info/s4/free-download-ringtones.html "> free download ringtones </a><a href=" http://xshorturl.info/s4/cheap-ringtones.html "> cheap ringtones </a><a href=" http://xshorturl.info/s4/free-cell-phone-ringtones.html "> free cell phone ringtones </a><a href=" http://xshorturl.info/s4/samsung-ringtones.html "> samsung ringtones </a><a href=" http://xshorturl.info/s4/free-motorola-ringtones.html "> free motorola ringtones </a><a href=" http://xshorturl.info/s4/lg-ringtones.html "> lg ringtones </a>[url=http://xshorturl.info/s4/free-nokia-ringtones.html]free nokia ringtones[/url][url=http://xshorturl.info/s4/free-download-ringtones.html]free download ringtones[/url][url=http://xshorturl.info/s4/cheap-ringtones.html]cheap ringtones[/url][url=http://xshorturl.info/s4/free-cell-phone-ringtones.html]free cell phone ringtones[/url][url=http://xshorturl.info/s4/samsung-ringtones.html]samsung ringtones[/url][url=http://xshorturl.info/s4/free-motorola-ringtones.html]free motorola ringtones[/url][url=http://xshorturl.info/s4/lg-ringtones.html]lg ringtones[/url][url=http://xshorturl.info/s4/free-verizon-ringtones.html]free verizon ringtones[/url]

lindijg - lindijg (2007年04月23日 05時48分10秒)

<a href=" http://xshorturl.info/s4/free-verizon-ringtones.html "> free verizon ringtones </a><a href=" http://xshorturl.info/s4/free-real-ringtones.html "> free real ringtones </a><a href=" http://xshorturl.info/s4/real-ringtones.html "> real ringtones </a><a href=" http://xshorturl.info/s4/mosquito-ringtones.html "> mosquito ringtones </a><a href=" http://xshorturl.info/s4/free-ringtones-download.html "> free ringtones download </a>[url=http://xshorturl.info/s4/free-real-ringtones.html]free real ringtones[/url][url=http://xshorturl.info/s4/real-ringtones.html]real ringtones[/url][url=http://xshorturl.info/s4/mosquito-ringtones.html]mosquito ringtones[/url][url=http://xshorturl.info/s4/free-ringtones-download.html]free ringtones download[/url]

lindiwk - lindiwk (2007年04月23日 07時19分54秒)

<a href=" http://xshorturl.info/s3/line-of-credit.html "> line of credit </a>

{{comment multi|w}}