Forum Moderators: coopster

Message Too Old, No Replies

need a bash script

its real easy

         

indiandomain

12:12 pm on Apr 25, 2004 (gmt 0)

10+ Year Member



hi guys
i have an input.txt file which has a name on each line

man
woman

the script must replace m with n and replace a with e.

so the output.txt would look like

nan
men
wonan
women

i knows its a darn easy script.

any help will be appreciated

hakre

1:44 pm on Apr 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think you want to do some of the stuff yourself, so here are some suggestions:

file_get_contents [php.net] will read the entire file into a string.

str_replace [php.net] will then replace anything in the string your want to.

what's left is to save the string into a file again. that's a little more work. the fopen [php.net] function will be needed to create the new file and fwrite [php.net] to save it. don't forget to apply fclose later on. anyways, in the last link there is a complete description how to save a file, so this will help you a lot. and anyways: each link contains detailed information about the function and sample code.

i think this should lead you to your script.

--hakre