首页 / LINUX / linux cut: invalid byte, character or field list Try 'cut --help' for more information.
linux cut: invalid byte, character or field list Try 'cut --help' for more information.
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了linux cut: invalid byte, character or field list Try 'cut --help' for more information.,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2583字,纯文字阅读大概需要4分钟。
内容图文
1. 概述
centos执行简单shell 脚本 报错
cut: invalid byte, character or field list
Try ‘cut --help‘ for more information.
2. 代码
vim userid.sh
#!/bin/bash #Program # Use id, finger command to check system account‘s information.#History #2015/07/17 logan first release PATH=/bin:$PATH export PATH users=$(cut -d ‘:‘ -fl /etc/passwd)#注意这行!!!!!!!!!!!!! for username in ${users} do id ${username} done
3. 解决问题
代码中cut命令 后跟的选项及参数有误 应该是数字1而不是字母l
4. cut 命令学习请参考 https://linuxconfig.org/learning-linux-commands-cut
以下为节选
Frequently used options Without too much talk let ‘ s start by introducing main and the most commonly used cut command line options. -b, --bytes=LIST Cuts the input file using list of bytes specified by this option -c, --characters=LIST Cuts the input file using list of characters specified by this option -f, --fields=LIST Cuts the input file using list of field. The default field to be used TAB. The default behavior can be overwritten by use of -d option. -d, --delimiter=DELIMITER Specifies a delimiter to by used as a field. As mentioned previously default field is TAB and this option overwrites thisdefault behavior. Using LIST List inthiscase can consist of single or range of bytes, characters or fields. For example to display only second byte the list will include a single number 2 . Therefore: 2 will display only second byte, character or field counted from12-5 will display all bytes, characters or fields starting from second and finishing by 5th -3 will display all bytes, characters or fields before 4th 5- will produce all bytes, characters or fields starting with 5th 1,3,6 will display only 1st, 3rd and 6th byte, character or field 1,3- displays 1st and all bytes, characters or fields starting with 3th Let‘s see how this works in practice. Cut by Character In the following examples are rather self-explanatory. We used cut‘s -c option to print only specific range of characters from cut.txt file. echo cut-command > cut.txt $ cut -c 2 cut.txt u $ cut -c -3 cut.txt cut $ cut -c 2-5 cut.txt ut-c $ cut -c 5- cut.txt command Cut By Byte The principle behind -b ( by byte ) option is similar to the one described previously. We know that a single character has size of 1byte and therefore result after executing previous commands with -b option will be exactly the same: $ cut -b 2 cut.txt u $ cut -b -3 cut.txt cut $ cut -b 2-5 cut.txt ut-c $ cut -b 5- cut.txt command
原文:http://www.cnblogs.com/rocky-fang/p/6709622.html
内容总结
以上是互联网集市为您收集整理的linux cut: invalid byte, character or field list Try 'cut --help' for more information.全部内容,希望文章能够帮你解决linux cut: invalid byte, character or field list Try 'cut --help' for more information.所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。