如何处理 cut --complement 命令的错误?
How to deal with an error in cut --complement command?
我在 cut
命令中遇到错误并试图找到解决方案但没有帮助。我有一个制表符分隔的文件,我通过管道将制表符替换为逗号。然后我使用 cut --complement
通过管道删除特定列,但出现此错误:
cut: [-cf] list: illegal list value
我的命令:
cat input.txt | grep -v '#' | tr '\t' ',' | cut -d ',' -f2,3,4,5,6 --complement | head
当我删除 --complement
时,它会打印列 2,3,4,5,6
但对于 --complement
它不起作用。
我们将不胜感激。
使用 awk
awk '/#/{next}{for(i =2;i<7;i++)$i=$(i+5);NF-=5}1;' FS=\t OFS=, input.txt
(请注意:这是我 phone 的第一篇文章。我在 termux 中使用 smtx 测试了上面的内容。但是......预计剪切 n 粘贴错误!)
BSD 剪辑没有 --complement
选项。在这种特定情况下,您可以使用:
cut -d , -f 1,7-
而不是
cut -d ',' -f2,3,4,5,6 --complement
我在 cut
命令中遇到错误并试图找到解决方案但没有帮助。我有一个制表符分隔的文件,我通过管道将制表符替换为逗号。然后我使用 cut --complement
通过管道删除特定列,但出现此错误:
cut: [-cf] list: illegal list value
我的命令:
cat input.txt | grep -v '#' | tr '\t' ',' | cut -d ',' -f2,3,4,5,6 --complement | head
当我删除 --complement
时,它会打印列 2,3,4,5,6
但对于 --complement
它不起作用。
我们将不胜感激。
使用 awk
awk '/#/{next}{for(i =2;i<7;i++)$i=$(i+5);NF-=5}1;' FS=\t OFS=, input.txt
(请注意:这是我 phone 的第一篇文章。我在 termux 中使用 smtx 测试了上面的内容。但是......预计剪切 n 粘贴错误!)
BSD 剪辑没有 --complement
选项。在这种特定情况下,您可以使用:
cut -d , -f 1,7-
而不是
cut -d ',' -f2,3,4,5,6 --complement