追加字符串壳输出 [英] Append string to output in shell

查看:207
本文介绍了追加字符串壳输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要追加/ *,从下面的CMD输出路径:

I want to append "/*" to the output paths from the below cmd:

查找/主页/ MBA /桌面/ð型-name日志。

我试着用下面的sed正则表达式:

I tried to use sed regex as below:

查找/主页/ MBA /桌面/ð型-name日志| SED -e'S /(^ )/ \\ 1 / /

find /home/mba/Desktop/ -type d -name "logs" | sed -e 's/(^.)/\1//'

但我得到下面的错误:
SED:-e前pression#1,烧焦14:未知的选项,以单曲

But I got the below error: sed: -e expression #1, char 14: unknown option to `s'

先谢谢了。

推荐答案

这是使用工作的解决方案 AWK

This is a working solution using awk:

find /home/mba/Desktop/ -type d -name "logs" | awk '{ print $1"/*" }'

,使用 SED

find /home/mba/Desktop/ -type d -name "logs" | sed 's/$/\/\*/'

这篇关于追加字符串壳输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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