How can I change spaces to underscores and lowercase everything?

Posted by benjamin button on Stack Overflow See other posts from Stack Overflow or by benjamin button
Published on 2009-11-27T12:42:48Z Indexed on 2010/06/09 7:12 UTC
Read the original article Hit count: 170

Filed under:
|
|
|

I have a text file which contains:

Cycle code
Cycle month
Cycle year
Event type ID
Event ID
Network start time

I want to change this text so that when ever there is a space, I want to replace it with a _. And after that, I want the characters to lower case letter like below:

cycle_code
cycle_month
cycle_year
event_type_id
event_id
network_start_time

How could I accomplish this?

© Stack Overflow or respective owner

Related posts about perl

Related posts about shell-scripting