Awk/sed script to convert a file from camelCase to underscores

后端 未结 4 735
灰色年华
灰色年华 2020-12-30 02:49

I want to convert several files in a project from camelCase to underscore_case.

I would like to have a onliner that only needs the filename

4条回答
  •  再見小時候
    2020-12-30 03:44

    You could use sed also.

    $ echo 'fooBar' | sed -r 's/([a-z0-9])([A-Z])/\1_\L\2/g'
    foo_bar
    $ echo 'fooBar' | sed 's/\([a-z0-9]\)\([A-Z]\)/\1_\L\2/g'
    foo_bar
    

提交回复
热议问题