免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 2718 | 回复: 10
打印 上一主题 下一主题

cut命令问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-06-24 13:27 |只看该作者 |倒序浏览
1.cut命令中-b与-c有什么区别啊。
who | cut -b 1-10
who | cut -c 1-10
这两例子也没有看出来有什么区别啊。

2.cut命令中的-n有什么作用啊?谁能举个例子啊?

论坛徽章:
15
2015年辞旧岁徽章
日期:2015-03-03 16:54:15双鱼座
日期:2015-01-15 17:29:44午马
日期:2015-01-06 17:06:51子鼠
日期:2014-11-24 10:11:13寅虎
日期:2014-08-18 07:10:55酉鸡
日期:2014-04-02 12:24:51双子座
日期:2014-04-02 12:19:44天秤座
日期:2014-03-17 11:43:36亥猪
日期:2014-03-13 08:13:51未羊
日期:2014-03-11 12:42:03白羊座
日期:2013-11-20 10:15:18CU大牛徽章
日期:2013-04-17 11:48:45
2 [报告]
发表于 2009-06-24 13:28 |只看该作者
-b list         The list following -b specifies  byte  posi-
                     tions  (for  instance, -b1-72 would pass the
                     first 72 bytes of each line). When -b and -n
                     are  used together, list is adjusted so that
                     no multi-byte character is split.

     -c list         The list following  -c  specifies  character
                     positions  (for  instance, -c1-72 would pass
                     the first 72 characters of each line).

论坛徽章:
0
3 [报告]
发表于 2009-06-24 13:36 |只看该作者
这个我也有,能不能举个例子说说到底有什么不同啊

论坛徽章:
0
4 [报告]
发表于 2009-06-24 13:39 |只看该作者
原帖由 zjgbkhm 于 2009-6-24 13:27 发表
1.cut命令中-b与-c有什么区别啊。
who | cut -b 1-10
who | cut -c 1-10
这两例子也没有看出来有什么区别啊。

2.cut命令中的-n有什么作用啊?谁能举个例子啊?



根据字节
       -b, --bytes=LIST
              output only these bytes

根据字符
       -c, --characters=LIST
              output only these characters

根据字节,但不拆分字符
       -n     with -b: don't split multibyte characters

论坛徽章:
0
5 [报告]
发表于 2009-06-24 13:41 |只看该作者
什么叫做根据字节,但不拆分字符啊,能不能举个例说明一下啊。

论坛徽章:
0
6 [报告]
发表于 2009-06-24 13:45 |只看该作者
还在吗?能不能举个例啊。先谢谢了。我实在是不知道有什么例子来说明-n的作用。

论坛徽章:
0
7 [报告]
发表于 2009-06-24 14:00 |只看该作者
  1. [root@Mylinux tmp]# echo "a 啊 b c"|cut -b 1-3
  2. a 半[root@Mylinux tmp]# echo "a 啊 b c"|cut -c 1-3
  3. a 啊
  4. [root@Mylinux tmp]# echo "a 啊 b c"|cut -n -b 1-3
  5. a
  6. [root@Mylinux tmp]# echo "a 啊 b c"|cut -n -b 1-5
  7. a 啊
复制代码

论坛徽章:
0
8 [报告]
发表于 2009-06-24 14:07 |只看该作者
我试了,不行啊
前三个结果都是a ?

我的系统是aix 和 sco

论坛徽章:
0
9 [报告]
发表于 2009-06-24 14:17 |只看该作者
谢谢,好像在ksh下不好用,但在bash下好用。

论坛徽章:
0
10 [报告]
发表于 2009-06-24 20:30 |只看该作者
  1. [root@localhost test]# echo "i阿好似阿" | cut -b 1-10
  2. i阿好似
  3. [root@localhost test]# echo "i阿好似阿" | cut -c 1-10
  4. i阿好似阿
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP