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. 2016级算法第二次上机-E.AlvinZH的儿时梦想——运动员篇

    862-AlvinZH的儿时梦想--运动员篇 思路 难题. 应该想到,不管给出的数据如何,每一个淘汰的人不会对最终答案产生任何影响,所以每次淘汰就把人除掉就可以了,最后剩下的两个人计算它们从开始到相遇 ...

  2. [转载] 第三篇:数据仓库系统的实现与使用(含OLAP重点讲解)

    阅读目录 前言 创建数据仓库 ETL:抽取.转换.加载 OLAP/BI工具 数据立方体(Data Cube) OLAP的架构模式 小结 回到顶部 前言 上一篇重点讲解了数据仓库建模,它是数据仓库开发中 ...

  3. Linux下配置redis,c#简单调用

    redis比较流行的nosql库: 我这里测试本机window系统,虚拟机安装linux系统,linux系统部署redis,windwo系统,c#调用linux系统的redis 第一步:linux下安 ...

  4. java多线程-ReadWriteLock

    大纲: ReadWriteLock接口 ReentrantReadWriteLock ReentrantReadWriteLock使用 一.ReadWriteLock public interface ...

  5. NestJS 用TypeScript开发 nodeJS后端

    NestJS A progressive Node.js framework for building efficient and scalable server-side applications ...

  6. uipath接入Python

    安装UiPath.Python.Activities,然后会有五个.Activities,他们的功能分别如下: 本人原创,转发或引用请注明出处.

  7. (转)Python random模块

    原文:https://my.oschina.net/cuffica/blog/33336 https://www.cnblogs.com/renpingsheng/p/7105296.html ran ...

  8. Jmeter基础元件

    测试计划 1.Test Plan (测试计划) 用来描述一个性能测试,包含与本次性能测试所有相关的功能.也就说JMeter创建性能测试的所有内容是于基于一个计划的. 下面看看一个计划下面都有哪些功能模 ...

  9. JVM的内存分配和回收策略

    对象的Class加载 虚拟机遇到一条new指令时,首先将去检查这个指令的参数是否能在常量池中定位到一个类的符号引用,并且检查这个符号引用代表的类是否已被加载.解析和初始化过.如果没有,那必须先执行相应 ...

  10. 学习笔记之--认识Xcode中的重要成员:lldb调试器

    之前对lldb调试器了解比较少,平时主要用来打印日志和暂定时用鼠标查看属性数据以及使用p po一些简单的命令语句. 今天看了一些关于lldb的文章,顿时觉得之前对它了解太少了,原来它还有那么多的功能. ...