Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用命令shell(例如bash)将camelCase中的(以空格分隔的)单词转换为snake_case的简单方法是什么?
相对于我已删除的较早问题,这是一个更简单的情况。
使用 GNU sed,您可以轻松地转换为小写字母并带有下划线前缀:
$ echo camelCase andAnother | sed 's/[A-Z]/_\l&/g' camel_case and_another