管道pipe 变量修饰器/管道:前者的输出是后者的输入参数。 linux的管道与smarty的变量修饰器使用效果一致。 输出的信息与预期信息不符合,需要通过中间介质(其他函数)对信息再进一步处理、过滤优化。 Smarty的变量修饰器: {$time | date_format:"%Y-%m-%d %H:%M:%S"} //date() {$title | upper} //strtoupper() {$content|upper|lower|XXX|YYY} 可以同时使用多个修饰器。 Smarty的变量修饰器比较固定,一共就20多个 linux的管道: 其中的许多指令(grep head tail wc ls等等)都可以当做管道符号使用. 管道使用相比smarty要灵活很多。 > ls -l | wc //计算当前目录一共有多少个文件 >grep sbin passwd | wc //计算passwd文件中出现sbin内容的行数 >ls -l | head -10 //以详细列表形式查看当前目录下前10个文件 >ls | grep apple //在当前目录下查找出现"apple"字样的文件名字 >ls -l | head -20 | tail -5 //查看当前目录中第16-20个文件信息