Muhammad Badawy
Muhammad Badawy

Reputation: 37

Append string to output in shell

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.

Upvotes: 2

Views: 199

Answers (2)

konsolebox
konsolebox

Reputation: 75588

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

Upvotes: 1

julienc
julienc

Reputation: 20355

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/$/\/\*/'

Upvotes: 1

Related Questions