bash - Capitalize the first letter of every word in a filename or directory in Shell -


i'm trying write shell command can specify directory, , every file , directory inside have first letter of every word capitalized.

/documents/test.txt

should change

/documents/test.txt

i'm thinking should start like

for in directory tr something_goes_here done 

the problem can't figure out how first letter. i've made script uppercase whole file name, can't figure out how first letter of every word.

thanks!

using gnu sed

you can quite gnu sed. example:

$ echo '/documents/test.txt' | sed 's!/.!\u&!g' /documents/test.txt 

limitations

note \u escape gnu sed extension. manual says:

finally, gnu 'sed' extension, can include special sequence made of backslash , 1 of letters 'l', 'l', 'u', 'u', or 'e'.

`\u' turn replacement uppercase until `\l' or `\e' found 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -