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 ...
随机推荐
- 2019.2.14 t3 车辆销售
用算法求最大生成树,在并查集合并时,把原本的一个根连向另一个 根改成两个根都连向一个新建的节点,并把当前正在处理的边的权值赋给这个新 节点做点权.这样形成的结构会是一棵树. 一个点的答案大致上是树的根 ...
- thinkphp3.2----实现伪静态和路由配置
URL模式: 0.普通 http://localhost/qixin/ThinkCMF(test)_backup/index.php?g=user&m=login&a=index ...
- c语言-学生成绩信息系统
#include<stdio.h> #define N 100 int Count=0; struct stu { int num; char name[20]; int computer ...
- ionic 学习 一
ionic 依赖angular.在学之前,我对angular进行了一下入门. 最近在看ionic,想做一些笔记,所以,写下这个随笔,有什么不对的请多多指教,刚开始学,后面还会学Apache Cordo ...
- Hacking Lambda Expressions in Java
Hacking Lambda Expressions in Javahttps://dzone.com/articles/hacking-lambda-expressions-in-java At t ...
- 如何实现java的四则运算
很多语言底层对四则运算都有内部封装, 我们还是要重复造下轮子,不为别的, 就是为了面试可以多装一分 b, 假设你已经了解了什么是二进制, 什么是异或, 什么是移位运算, 什么是与, 这些不懂就别硬上( ...
- 认识CSS中盒子模型
前端之HTML,CSS(六) CSS 盒子模型 CSS中的重点,理解盒子模型对于CSS才能有更清晰的认识.网页说简单一点其实就是一块一块的拼接出来的,可以想象成拼图,所有图块拼接在一起就成了一幅图像. ...
- Linux Shell脚本编程基础
1. 脚本是一个包含一系列命令序列的文本文件,当运行这个脚本文件时,文件中包含的命令序列将得到执行. 2. 脚本主要由两部分组成:脚本解释器和命令序列 注:#!/bin/bash 指明脚本解释器为Ba ...
- git笔记记录
廖雪峰Git教程学习记录. 0.常用命令总结: pwd 命令用于显示当前目录 git init 命令把这个目录(自己建的文件夹)变成Git可以管理的仓库(必须切换到当前文件夹下面执行这个命令) ls ...
- Python——模块以及导入注意事项
在Python中,每一个文件都应该是可以被导入的. 每一个独立的python文件都是一个模块 在导入文件时,文件中所有没有任何缩进的代码都会被执行一遍. 而在实际应用时,每个模块都是有专人负责独立开发 ...