linux cut: invalid byte, character or field list Try 'cut --help' for more information.
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.的更多相关文章
- 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 ...
- maven filter 乱码,MalformedByteSequenceException: Invalid byte 3 of 3-byte UTF-8 sequence.
<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactI ...
- MalformedByteSequenceException: Invalid byte 1 of 1-byte
修改了线上程序的xml配置文件,重启后报如下错误: MalformedByteSequenceException: Invalid byte 1 of 1-byte 百度了下大体的意思是说文件的编码错 ...
- [字符编码]Invalid byte 1 of 1-byte UTF-8 sequence终极解决方案
今天在eclipse中编写pom.xml文件时,注释中的中文被eclipse识别到错误:Invalid byte 1 of 1-byte UTF-8 sequence,曾多次遇到该问题,问题的根源是: ...
- 读取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- ...
- warning: #870-D: invalid multibyte character sequence
warning: #870-D: invalid multibyte character sequence2011-03-12 9:18warning: #870-D: invalid multiby ...
- Invalid byte 3 of 3-byte UTF-8 sequence
用maven编译,tomcat启动时报错:IOException parsing XML document from class path resource [applicationContext.x ...
- 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 ...
- tomcat部署新的项目的时候出现报错信息: Invalid byte tag in constant pool: 15
上面一堆tomcat启动的提示信息省略掉,下面是报错的具体信息:org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid ...
随机推荐
- <b>与<strong> <em>与<i>标签的区别
<b>与 <strong>用在网页上都能使字体加粗,二者的不同是:<b>是物理元素 ;<strong>是逻辑元素. 物理元素强调的是一种物理行为.比如说 ...
- LOJ565. 「LibreOJ Round #10」mathematican 的二进制(NTT)
题目链接 https://loj.ac/problem/565 题解 首先,若进行所有操作之后成功执行的操作数为 \(m\),最终得到的数为 \(w\),那么发生改变的二进制位的数量之和(即代价之和) ...
- js高级程序设计 笔记 --- 错误处理、json和ajax
1,错误处理 1,try-catch语句 try{可能导致错误的代码} catch(error) {在错误发生时该怎么处理} error.message是所有浏览器都支持的属性. finally语句是 ...
- [转] java获取hostIp和hostName
[From] https://www.cnblogs.com/huluyisheng/p/6867370.html InetAddress的构造函数不是公开的(public),所以需要通过它提供的静态 ...
- 论文阅读 | CenterNet:Object Detection with Keypoint Triplets
相关链接 论文地址:https://arxiv.org/abs/1904.08189 代码链接:https://github.com/Duankaiwen/CenterNet 概述 CenterNet ...
- Locust 类的使用
HttpLocust类 可定义多个HttpLocust类,即多个用户可执行不同的任务或者相同的任务,但是执行频率不一样,用weight进行约定. # coding:utf-8 from locust ...
- vue 打印
vue 方法 第一种方法:通过npm 安装插件 1,安装 npm install vue-print-nb --save 2,引入 安装好以后在main.js文件中引入 import Print ...
- jsp基础知识总结
1.了解jsp,jsp有什么有利的,有什么弊端. jsp是serlet的扩展,在web应用中,每个jsp页面都会有servlet容器生产对应的servlet. jsp通过在标准的html页面中插入ja ...
- es中的date类型
JSON中没有date类型,es中的date可以由下面3种方式表示: ①格式化的date字符串,例如"2018-01-01"或者"2018-01-01 12:00:00& ...
- 配置mybatis解决log4j未正常打印sql的问题
在mybatis-config.xml中增加配置: <settings> <setting name="logImpl" value="STDOUT_L ...