+ -
当前位置:首页 → 问答吧 → 求助 关于shell 工具

求助 关于shell 工具

时间:2011-05-09

来源:互联网

遇到个作业 教授要求只能用 standard shell 编写,不能用shell tools
我怎么区分哪个是tools
还有就是 如果文档中 存的 数据格式 是  我; 你; 她; 你们
怎么输出 不用shell 工具 输出成



他们
另外就是 查找 怎么在文件中根据关键字查找这句话 不用shell工具

作者: hanxu588   发布时间: 2011-05-09

  1. #!/bin/bash
  2. split () {
  3.     while [ $1 ]
  4.     do
  5.         echo "$1"
  6.         shift
  7.     done
  8. }

  9. while read line
  10. do
  11.     split ${line//;/ }
  12. done < urfile
复制代码
#cat urfile
I;You;She
#./test.sh
I
You
She

作者: Shell_HAT   发布时间: 2011-05-10

  1. split () {
  2.     while [ $1 ]
  3.     do
  4.         echo "$1"
  5.         shift
  6.     done
  7. }

  8. IFS=\;
  9. while read line
  10. do
  11.     split $line
  12. done < urfile
复制代码

作者: Shell_HAT   发布时间: 2011-05-10