2011年11月15日 星期二

Linux Pipe小工具

Linux sort的常用
按照第5個字段進行排序
[root@test2 smartlsData]# ll | sort -t : +5n-rwxrwxrwx 1 root root 178718700 12月22 18:40 Poi.bal-rwxrwxrwx 1 root root 182348152 12月22 18:40 Poi.bas-rwxrwxrwx 1 root root 18441600 12月22 18:40 Poi.ndx-rwxrwxrwx 1 root root 194056 2006-08-29 wordTableEntry.txt-rwxrwxrwx 1 root root 194056 9月15 16:31 GeoWordTableEntry.txt-rwxrwxrwx 1 root root 20580 12月22 18:40 ACode.ndx-rwxrwxrwx 1 root root 338304 2006-08-10 AnTable.txt-rwxrwxrwx 1 root root 43680 2006-08-10 CnTable.txt-rwxrwxrwx 1 root root 4929920 2006-08-29 wordTable.txt-rwxrwxrwx 1 root root 4929920 9月15 16:31 GeoWordTable.txt-rwxrwxrwx 1 root root 6664 9月14 16:25 data.xml-rwxrwxrwx 1 root root 9220800 12月22 18:40 LsID.idx
按照純數字進行排序(否則按照字母方式進行排序)
[root@test2 smartlsData]# ll | sort -n-rwxrwxrwx 1 root root 178718700 12月22 18:40 Poi.bal-rwxrwxrwx 1 root root 182348152 12月22 18:40 Poi.bas-rwxrwxrwx 1 root root 18441600 12月22 18:40 Poi.ndx-rwxrwxrwx 1 root root 194056 2006-08-29 wordTableEntry.txt-rwxrwxrwx 1 root root 194056 9月15 16:31 GeoWordTableEntry.txt-rwxrwxrwx 1 root root 20580 12月22 18:40 ACode.ndx-rwxrwxrwx 1 root root 338304 2006-08-10 AnTable.txt-rwxrwxrwx 1 root root 43680 2006-08-10 CnTable.txt-rwxrwxrwx 1 root root 4929920 2006-08-29 wordTable.txt-rwxrwxrwx 1 root root 4929920 9月15 16:31 GeoWordTable.txt-rwxrwxrwx 1 root root 6664 9月14 16:25 data.xml-rwxrwxrwx 1 root root 9220800 12月22 18:40 LsID.idx總用量 390484


Linux wc 的使用
wc -l 行號
wc -m
wc -w
[root@test2 smartlsData]# ll | wc -l13
替換
[root@test2 smartlsData]# ll | tr -d 'A'總用量 390484-rwxrwxrwx 1 root root 20580 12月22 18:40 Code.ndx-rwxrwxrwx 1 root root 338304 2006-08-10 nTable.txt-rwxrwxrwx 1 root root 43680 2006-08-10 CnTable.txt-rwxrwxrwx 1 root root 6664 9月14 16:25 data.xml-rwxrwxrwx 1 root root 194056 9月15 16:31 GeoWordTableEntry.txt-rwxrwxrwx 1 root root 4929920 9月15 16:31 GeoWordTable.txt-rwxrwxrwx 1 root root 9220800 12月22 18:40 LsID.idx-rwxrwxrwx 1 root root 178718700 12月22 18:40 Poi.bal-rwxrwxrwx 1 root root 182348152 12月22 18:40 Poi.bas-rwxrwxrwx 1 root root 18441600 12月22 18:40 Poi.ndx-rwxrwxrwx 1 root root 194056 2006-08-29 wordTableEntry.txt-rwxrwxrwx 1 root root 4929920 2006-08-29 wordTable.txt
[root@test2 smartlsData]# ll | cut -d " " -f 4
 
rootrootrootrootrootrootrootrootrootrootrootroot
拆分 按照大小 和 行 來拆分
split -b 1m detailWebsite.htm detailWebsite.htm_split -l 5 detailWebsite.htm detailWebsite.htm_

yum 收藏的php pear庫

yum list |grep php-pear|cut -d " " -f 1
php-pear.noarch
php-pear-Auth.noarch
php-pear-Auth-OpenID.noarch
php-pear-Auth-RADIUS.noarch
php-pear-Auth-SASL.noarch
php-pear-Auth-Yubico.noarch
php-pear-Auth-radius.noarch
php-pear-Auth-samba.noarch
php-pear-Auth_HTTP.noarch
php-pear-Benchmark.noarch
php-pear-CAS.noarch
php-pear-Cache.noarch
php-pear-Cache-Lite.noarch
php-pear-CodeGen.noarch
php-pear-CodeGen-PECL.noarch
php-pear-Console-Color.noarch
php-pear-Console-CommandLine.noarch
php-pear-Console-Getargs.noarch
php-pear-Console-ProgressBar.noarch
php-pear-Console-Table.noarch
php-pear-Crypt-Blowfish.noarch
php-pear-Crypt-CHAP.noarch
php-pear-DB.noarch
php-pear-DB-DataObject.noarch
php-pear-DB-DataObject-FormBuilder.noarch
php-pear-DB-QueryTool.noarch
php-pear-Date.noarch
php-pear-Date-Holidays.noarch
php-pear-Date-Holidays-USA.noarch
php-pear-Event-Dispatcher.noarch
php-pear-File.noarch
php-pear-File-Bittorrent2.noarch
php-pear-File-Find.noarch
php-pear-File-Passwd.noarch
php-pear-File-SMBPasswd.noarch
php-pear-HTML-Common.noarch
php-pear-HTML-QuickForm.noarch
php-pear-HTML-QuickForm-ElementGrid.noarch
php-pear-HTML-QuickForm-advmultiselect.noarch
php-pear-HTML-Table.noarch
php-pear-HTML-Template-IT.noarch
php-pear-HTML_Javascript.noarch
php-pear-HTML_Template_PHPLIB.noarch
php-pear-HTTP.noarch
php-pear-HTTP-Client.noarch
php-pear-HTTP-OAuth.noarch
php-pear-HTTP-Request.noarch
php-pear-HTTP-Request2.noarch
php-pear-HTTP-Upload.noarch
php-pear-Image-Canvas.noarch
php-pear-Image-Color.noarch
php-pear-Image-Graph.noarch
php-pear-Image-GraphViz.noarch
php-pear-Log.noarch
php-pear-MDB2.noarch
php-pear-MDB2-Driver-mysql.noarch
php-pear-MDB2-Driver-mysqli.noarch
php-pear-MDB2-Driver-pgsql.noarch
php-pear-MDB2-Schema.noarch
php-pear-Mail.noarch
php-pear-Mail-Mime.noarch
php-pear-Mail-mimeDecode.noarch
php-pear-Math-Stats.noarch
php-pear-Net-Curl.noarch
php-pear-Net-DIME.noarch
php-pear-Net-DNS.noarch
php-pear-Net-FTP.noarch
php-pear-Net-IDNA2.noarch
php-pear-Net-IPv4.noarch
php-pear-Net-POP3.noarch
php-pear-Net-Ping.noarch
php-pear-Net-SMTP.noarch
php-pear-Net-Sieve.noarch
php-pear-Net-Socket.noarch
php-pear-Net-Traceroute.noarch
php-pear-Net-URL.noarch
php-pear-Net-URL-Mapper.noarch
php-pear-Net-URL2.noarch
php-pear-Net-UserAgent-Detect.noarch
php-pear-Numbers-Roman.noarch
php-pear-Numbers-Words.noarch
php-pear-OLE.noarch
php-pear-PEAR-Command-Packaging.noarch
php-pear-PHP-CodeSniffer.noarch
php-pear-PHP-Compat.noarch
php-pear-PHP-CompatInfo.noarch
php-pear-Pager.noarch
php-pear-Payment-Process.noarch
php-pear-PhpDocumentor.noarch
php-pear-PhpDocumentor-docs.noarch
php-pear-SOAP.noarch
php-pear-Services-Twitter.noarch
php-pear-Services-Weather.noarch
php-pear-Spreadsheet-Excel-Writer.noarch
php-pear-Structures-DataGrid.noarch
php-pear-Structures-DataGrid-DataSource-Array.noarch
php-pear-Structures-DataGrid-DataSource-DataObject.noarch
php-pear-Structures-DataGrid-DataSource-MDB2.noarch
php-pear-Structures-DataGrid-DataSource-RSS.noarch
php-pear-Structures-DataGrid-Renderer-Pager.noarch
php-pear-Structures-DataGrid-Renderer-Smarty.noarch
php-pear-Text-Diff.noarch
php-pear-Validate.noarch
php-pear-Validate-Finance-CreditCard.noarch
php-pear-Var-Dump.noarch
php-pear-XML-Beautifier.noarch
php-pear-XML-Parser.noarch
php-pear-XML-RPC2.noarch
php-pear-XML-RSS.noarch
php-pear-XML-Serializer.noarch
php-pear-phing.noarch



Additional PEAR Library

PHPUnit (for Unit Testing)

PHPMailer

Zend Framework

PEAR Package - Excel and Spreadsheet (Reference Only)


Reference

PHP - Email

Bounce Email Tracking

PHP Bulk Email - Best Practice

phplist Features

Wiki

Software

2011年11月14日 星期一

Zend Framework 輸出xml的幾種方法

Zend Framework 輸出xml的幾種方法。
 見代碼:1.



    class TestController extends Zend_Controller_Action {
        
/**
         
* The default action - show the home page
         
*/
        
public function indexAction() {
            
$content = "bar";
            
header('Content-Type: text/xml');
            
echo $content;
            
exit;
        
}
    
}





加一句exit;這樣可以不用關閉view.
2.

    
class TestController extends Zend_Controller_Action {
        
/**
         
* The default action - show the home page
         
*/
        
public function indexAction() {
         
// XML-related routine
            
$xml = new DOMDocument('1.0', 'utf-8');
            
$xml->appendChild($xml->createElement('foo', 'bar'));
            
$output = $xml->saveXML();
            
// Both layout and view renderer should be disabled
            
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true);
            
Zend_Layout::getMvcInstance()->disableLayout();
  
            
// Setting up headers and body
            
$this->_response->setHeader('Content-Type', 'text/xml; charset=utf-8')
                    
->setBody($output);
        
}
  
    
}
第二種方法可以調用DOMDocument對象來創建更豐富的xml.
本文出自“Bob” 博客,請務必保留此出處http://phpbob.blog.51cto.com/636017/631102