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
#// 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 this default behavior.
Using LIST List in this case 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 . Therefore: will display only second byte, character or field counted from
- will display all bytes, characters or fields starting from second and finishing by 5th
- will display all bytes, characters or fields before 4th
- will produce all bytes, characters or fields starting with 5th
,, will display only 1st, 3rd and 6th byte, character or field
,- 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 cut.txt
u
$ cut -c - cut.txt
cut
$ cut -c - cut.txt
ut-c
$ cut -c - 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 byte and therefore result after executing previous commands with -b option will be exactly the same: $ cut -b cut.txt
u
$ cut -b - cut.txt
cut
$ cut -b - cut.txt
ut-c
$ cut -b - cut.txt
command

linux cut: invalid byte, character or field list Try 'cut --help' for more information.的更多相关文章

  1. UTF-8 Invalid Byte Sequences

    Chances are, some of you have run into the issue with the invalid byte sequence in UTF-8 error when ...

  2. maven filter 乱码,MalformedByteSequenceException: Invalid byte 3 of 3-byte UTF-8 sequence.

    <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactI ...

  3. MalformedByteSequenceException: Invalid byte 1 of 1-byte

    修改了线上程序的xml配置文件,重启后报如下错误: MalformedByteSequenceException: Invalid byte 1 of 1-byte 百度了下大体的意思是说文件的编码错 ...

  4. [字符编码]Invalid byte 1 of 1-byte UTF-8 sequence终极解决方案

    今天在eclipse中编写pom.xml文件时,注释中的中文被eclipse识别到错误:Invalid byte 1 of 1-byte UTF-8 sequence,曾多次遇到该问题,问题的根源是: ...

  5. 读取xml文件报错:Invalid byte 2 of 2-byte UTF-8 sequence。

    程序读取xml文件后,系统报“Invalid byte 2 of 2-byte UTF-8 sequence”错误,如何解决呢? 1.程序解析xml的时候,出现Invalid byte 2 of 2- ...

  6. warning: #870-D: invalid multibyte character sequence

    warning: #870-D: invalid multibyte character sequence2011-03-12 9:18warning: #870-D: invalid multiby ...

  7. Invalid byte 3 of 3-byte UTF-8 sequence

    用maven编译,tomcat启动时报错:IOException parsing XML document from class path resource [applicationContext.x ...

  8. com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte

    com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte ...

  9. tomcat部署新的项目的时候出现报错信息: Invalid byte tag in constant pool: 15

    上面一堆tomcat启动的提示信息省略掉,下面是报错的具体信息:org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid ...

随机推荐

  1. selenium自动加载Flash

    当我们在定位的时候,有时候会碰到Flash问题导致无法定位到元素 通过下面的代码就能解决问题 参考:https://blog.csdn.net/qq_37913997/article/details/ ...

  2. 牛客网NOIP赛前集训营-提高组(第四场)B区间

    牛客网NOIP赛前集训营-提高组(第四场)B区间 题目描述 给出一个序列$ a_1  \dots   a_n$. 定义一个区间 \([l,r]\) 是好的,当且仅当这个区间中存在一个 \(i\),使得 ...

  3. P1444 [USACO1.3]虫洞wormhole

    luogu P1444 [USACO1.3]虫洞wormhole 首先感谢ghj的讲解 题目描述 农夫约翰爱好在周末进行高能物理实验的结果却适得其反,导致N个虫洞在农场上(2<=N<=12 ...

  4. 集合之四:List接口

    查阅API,看List的介绍.有序的 collection(也称为序列).此接口的用户可以对列表中每个元素的插入位置进行精确地控制.用户可以根据元素的整数索引(在列表中的位置)访问元素,并搜索列表中的 ...

  5. PHP 数组与CSV文件互转

    项目说明 数组导出CSV,ZIP文件,CSV,ZIP文件还原数组(Array export file,file restore array)适用于导入导出会员,商品信息注意:读取中文文件名文件.数据时 ...

  6. AVL树插入(Python实现)

    建立AVL树 class AVLNode(object): def __init__(self,data): self.data = data self.lchild = None self.rchi ...

  7. VS2013下使用cjson

    想要在C++实现json文件的读取.因为中间也遇到过很简单的坑,为了增加记忆,对实现过程做一个记录. 本文采用的是静态链接库的方式: 1.先在github上下载源码, json源码下载地址 2.打开m ...

  8. Python学习 day12

    一.@wraps __name__    查看函数的名字 __doc__   查看函数的文档字符串 例: def func(arg): """ 这是一个测试函数,这里是函 ...

  9. Spring Roo 想知道源码,怎么实现自动生成枯燥的有规律的文件

    简介   似乎是社区在维护的,不在 Spring 官网的 main projects 列表里,而是在 社区projects 列表里   是工具,不是像Spring Boot 一样的框架 http:// ...

  10. app接口,如何保证是由app内部调用而非外部模拟post请求调用。

    在爬虫快手主播信息的时候,发现只要我改动一下参数,比如第一页 page=1的时候,需要爬下一页,把page改为2发现提示sign验证失败了 也就是说,快手在开发的时候考虑了有人抓包到接口后,通过修改参 ...