我已经产生了下面的下面的文本文件:如何删除列?
fe120b99164f151b28bf86afa6389b22 -rw-r--r-- 1 joey joey 186 2010-03-14 19:26 Descript.txt
41705ea936cfc653f273b5454c1cdde6 -rw-r--r-- 1 joey joey 30 2010-03-14 20:29 listof.txt
0e25cca3222d32fff43563465af03340 -rw-r--r-- 1 joey joey 28 2010-03-14 23:35 sedexample.txt
d41d8cd98f00b204e9800998ecf8427e -rw-r--r-- 1 joey joey 0 2010-02-16 15:11 test1.txt
d41d8cd98f00b204e9800998ecf8427e -rw-r--r-- 1 joey joey 0 2010-02-16 15:11 test2.txt
d41d8cd98f00b204e9800998ecf8427e -rw-r--r-- 1 joey joey 0 2010-02-16 15:11 test3.txt
d41d8cd98f00b204e9800998ecf8427e -rw-r--r-- 1 joey joey 0 2010-02-16 15:11 test4.txt
d41d8cd98f00b204e9800998ecf8427e -rw-r--r-- 1 joey joey 0 2010-02-16 15:11 test5.txt
d41d8cd98f00b204e9800998ecf8427e -rw-r--r-- 1 joey joey 0 2010-02-16 15:11 test6.txt
f5c7f1856249d0526be10df5bd5b895a -rw-r--r-- 1 joey joey 26 2010-03-13 14:13 testingfile.txt
d41d8cd98f00b204e9800998ecf8427e -rw-r--r-- 1 joey joey 0 2010-03-15 00:28 uniquelist.txt
基本上我想摆脱接入,金额栏,用户和组列。换句话说,我想摆脱3,4,5列。我曾尝试使用剪切来保留我想要的列,然后以“”作为我的分隔符,但是由于文件大小的数字,它使用“空格”作为分隔符来混淆。任何意见将不胜感激!哦,只需添加,我想将输出保存为另一个文本文件。非常感谢!
我的原始剪切命令是这样的: more indexfile.txt | cut -d“”-f 1,6,7,8,9> goodindex.txt –
非常感谢您的帮助!你的解决方案很完美! –
@Joey jie:如果您不清楚为什么您的初始* cut *有时会删除时间和/或文件名:大小(?)列中的额外填充空格会在* cut *内部创建额外的空字段。这导致您的字段枚举在某些情况下太短。如果你使用了'-f1,6,7,8,9,10,11',它就可以工作,但显然'-f1,6-'更简洁灵活。如果要删除第一个填充空格的列之外的字段,则需要使用其他解决方案。如果所有列(包括要删除的列之前的列)具有固定的宽度,也许'cut -c'。 –