Append string to output in shell

六月ゝ 毕业季﹏ 提交于 2020-01-04 06:28:08

问题


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

find /home/mba/Desktop/ -type d -name "logs"

I tried to use sed regex as below:

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

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

Thanks in advance.


回答1:


This is a working solution using awk:

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

Or with sed:

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



回答2:


find /home/mba/Desktop/ -type d -name "logs" -printf '%p/*\n'


来源:https://stackoverflow.com/questions/24841899/append-string-to-output-in-shell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!