如何在bash中删除字符串的第一部分? [英] How to remove the first part of a string in bash?

查看:51
本文介绍了如何在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中删除字符串的第一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆