English 中文(简体)
使用剪切[复制]打印最后一个字段
原标题:Print the last field using cut [duplicate]

比方说,我删除了以下数据:

ae722d1d94dcd3b161af166936:!]z@.:123
09338b2b29919e6c0daefbcce0361335:21f2e48d86f28ab7cd5c9c95:123
$H$92Gh.gRJwECLPzkjACPihoLg/:123
c6f1cb5f1feeece60f9a8e067e0:v4Zz Cj5_Ze{J+iRW{2z,<~:123
202cb962a75b964b07152d234b70:123
40bd0015630c35165329ea5ecbdbbeef:123

(Invaild hashes,仅为解释目的)

我想使用 cuter 工具只打印最后一个字段 。

123
123
123
123
123
123
  • I don t want to use rev command.
  • I want nothing other than cut, I know how to do it in sed, awk.

-compulate 旗可能有用!

问题回答

对于这一具体数据,您可以:

cut -f2- -d: file | cut -f2 -d:

如果你可能有三个结肠:

cut -f2- -d: file | cut -f2- -d: | cut -f2 -d:

您可以继续根据需要添加更多 cuter

诀窍是 cucut 对没有分隔符的记录没有任何作用, 这样您就可以使用连续的 cucut 来切除第一个字段, 而留下您已经找到的最后字段 。

我在另一个地方看到这个 当我在寻找这个答案。

rev, cut(在分隔符上) -f 1, rev

向前移动最后一个字段, 切开它, 然后往后移

我以为那有点滑滑





相关问题
KornShell- Creating a fixed width text file

I need to create a simple fixed width text file in KornShell (ksh). My current attempt using printf to pad the string isn t working out very well. What s the shortest, cleanest way to create a fixed ...

unix find command

how to use the find command to find files/directories which are not matching the pattern. for eg: find <some options > -name "dontfile.txt" should give me output of all the find whose file ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Case insensitive comparison of strings in shell script

The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?

1. 露台式照像

在Windows XP中,没有一时出现指挥时,是否有办法操作一种灰色文字? 我常常需要把“善待”(工作)与“灰色”同起来,即使我的文字没有产出,......

热门标签