You are here: Re: PHP scripting... An similiar awk command « PHP Programming Language « IT news, forums, messages
Re: PHP scripting... An similiar awk command

Posted by Chung Leong on 11/01/06 14:22

Anthony Smith wrote:
> Greetings,
>
> I have the need to take a file and remove the trailing white space as
> well as any empty lines... I inherited this script:
>
>
> cat $1 | awk -v quote="'" \
> '
> /^[ ]*$/ { next; }
> /^.*[ ]*$/ {
> printf ("%s\n",substr ($0,1,match($0, "[
> ]*$")-1));
> next;
> }
> { print $0; }
> '
>
>
> I prefer to do it in PHP. Is there a simpler way?

$a = file($filename);
$a = array_filter(array_map('rtrim', $a));

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация