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 ...
随机推荐
- 正则表达式 python
下面这种方式 从结果上看 匹配的是关键字, 但是不是 每一次都可以 100% 准确 search_words_dict = { "肠炎宁": 0, "维生素AD" ...
- 为 JSON 字符串创建对象
---------------------------页面效果---------------------------------- ---------------------------代码实现--- ...
- jenkins 判断是手动触发还是定时器触发
根据变量BUILD_CAUSE的值可以判断本次触发是手动触发还是定时器触发 手动触发:MANUALTRIGGER 定时器触发:TIMERTRIGGER
- 串口通信n
1.USART_Init(参数1,参数2) 串口配置步骤 1.串口时钟使能,GPIO使能 2.串口复位 3.端口模式设置GPIO_Init() 4.串口参数初始化USART_Init() 5,使能串口 ...
- 引入background和background-size不显示图片
.bgLeft { position: absolute; left: -95px; background: url("../images/logo_1.png") left to ...
- 用PL/sql连接oracle 弹窗出现 could not resolve the connect identifier specified 这个错误
1 错误如下图: 图1 2.可能原因: 配置oracle客户端中tnsnames.ora文件时,把数据库名弄错,如下图: 图2 箭头所指位置出错.箭头处应该为我们安装时的数据库名(通常是orcl).而 ...
- word-wrap:表示是否允许流浪器断句,word-break:表示怎样断句
word-wrap: break-word的话,流浪器可以断句,但是是按单词形式断句. 而加上 word-break: break-all的话,单词内部也断句. "whiteSpace&qu ...
- jmeter调试脚本之变量参数化
前言 对于参数化,觉得用得最多的应该是csvread函数.csv data config以及用户自定义变量(前一篇文章已经进行了讲解)控制器这几个 案例:bugfree ,提交bug,参数bug名称和 ...
- Unity5.x在mac下的破解
工具下载 http://www.ceeger.com/forum/read.php?tid=23396&uid=24111 破解unity5.x版本亲测有效 但是他的说明不详细 下载后,里面有 ...
- Cucumber capybara 每个Scenario登陆一次
hook.rb中添加: After do |scenario| Capybara.current_session.instance_variable_set(:@touched, false)end ...