LinuxÒÁµéÔ°ÂÛ̳'s Archiver

stephenzsh ·¢±íÓÚ 2007-2-17 12:03

ÐÂÊÖÔÚÏß¼±ÎÊSHELL£¬Ð»Ð»£¡

ÎļþÄÚÈÝÈçÏ£¨×îºóÒ»ÐÐÊÇÎļþ»»ÐУ©£º
00000346130
00000346131
20070209|000020|0000016782000|01|

ÎÒÏÖÔÚÏë°Ñ¡°20070209|000020|0000016782000|01|¡±·Åµ½µÚÒ»ÐУ¬ÐèÒªµÄ½á¹ûÈçÏ£º
20070209|000020|0000016782000|01|
00000346130
00000346131

ÇëÎÊÔÚLINUX»òUNIXÓÐʲôÃüÁî»ò·½·¨ÊµÏÖÄØ£¿ÏÈлл£¡

li-jiahuan ·¢±íÓÚ 2007-2-19 13:52

I do not find a simple way using bash ...

[php]
huan@huan:~/test$ cat process.pl
#! /usr/bin/perl -w

use Tie::File;

my @arr;
tie @arr, 'Tie::File', shift or die $@;
my $cnt = scalar @arr;
($arr[0], $arr[$cnt - 2]) = ($arr[$cnt - 2], $arr[0]);

huan@huan:~/test$ cat txt
00000346130
00000346131
20070209|000020|0000016782000|01|

huan@huan:~/test$ perl process.pl txt
huan@huan:~/test$ cat txt
20070209|000020|0000016782000|01|
00000346131
00000346130

huan@huan:~/test$
[/php]

stephenzsh ·¢±íÓÚ 2007-2-25 09:23

лл°ßÖñ!!!

Ò³: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.