如何在bash中删除字符串的第一部分?

编程入门 行业动态 更新时间:2024-10-08 13:38:01
本文介绍了如何在bash中删除字符串的第一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这段代码将给出第一部分,但是如何删除它,并获得没有第一部分的整个字符串呢?

This code will give the first part, but how to remove it, and get the whole string without the first part?

echo "first second third etc"|cut -d " " -f1

推荐答案

您应该看一下信息剪切,它将解释 f1 的含义.另外,这里是一个相同的问题: question-7814205

You should have a look at info cut, which will explain what f1 means. Also, a same question here: question-7814205

实际上,我们只需要第二个字段之后的字段. -f 告诉命令按字段搜索,而 2-表示第二个和后续字段.

Actually we just need fields after(and) the second field. -f tells the command to search by field, and 2- means the second and following fields.

echo "first second third etc" | cut -d " " -f2-

更多推荐

如何在bash中删除字符串的第一部分?

本文发布于:2023-10-31 06:57:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545355.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   第一部分   如何在   bash

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!