Jonus1993
Jonus1993

Reputation: 31

Find and change each 1st char of directory in path string

It's my 1st script in bash and I'm making a script that the bitbucket pipeline will use. I'm trying to change each 1st letter of the directory to lowerCase. E.g.

database/Seeders/Entities/Users/Earnings/UserEarningsReportSeeder

will be changed on

database/seeders/entities/users/earnings/userEarningsReportSeeder

Trying with this but not working properly for me :(

echo "$(echo "$Line" | sed 's/\/[A-Z]/\/L&/g')"

Upvotes: 2

Views: 56

Answers (1)

Gilles Quénot
Gilles Quénot

Reputation: 185053

Like this (you was very close):

$ sed 's@/[A-Z]@\L&@g' <<< 'Database/Seeders/EarningsFoo'

The separator can be any ASCII character, here @

Output

database/seeders/earningsFoo

Upvotes: 2

Related Questions