Search code examples
bashlowercase

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')"


Solution

  • 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