How to insert a character in line in Special condition?

Hi,
I have a log file generated by a tool which has the following look :

/tmp/releases/directory/datefilename1_release_date.zip
/tmp/releases/directory/datefilename2_release_date.zip
/tmp/releases/directory/datefilename3_release_date.zip
/tmp/releases/directory/datefilename4_release_date.zip

Clearly you can identify the path generated for the each file by that tool is broken because there exists no "/" between date directory and the filename . I want to insert a "/" between the "date" and "filename" so that it becomes complete because this path is fed to another tool.
It should look like :

/tmp/releases/directory/date/filename1_release_date.zip
/tmp/releases/directory/date/filename2_release_date.zip
/tmp/releases/directory/date/filename3_release_date.zip
/tmp/releases/directory/date/filename4_release_date.zip

I tried with sed but did not know how to proceed. Please help . Thanks in advance.

Assuming you have real dates instead of "release_date" in your file:

sed 's!\(.*date\)\(.*\)!\1/\2!'  file

Regards

Hi ,
Thanks for your reply but it working partially . Actually the the line looks like
/tmp/night_release/proj_release_20090416Filename_release_1_0_20090416.zip

Need to look like

/tmp/night_release
/proj_release_20090416/Filename_release_1_0_20090416.zip

Regards,

Should be something like:

sed 's!\(.*\)\(Filename.*\)!\1/\2!'  file

Hi ,
Thanks for this reply it is working now. But is it good way to proceed ? because filename is different for different line In that case I have to write an another script to cut the file names and replace it with each time. Your suggetions?

Try this:

sed s'!\(.*[0-9]\{8\}\)\(.*[0-9]\{8\}.*zip\)!\1/\2!' file

Hi,
This time it worked perfectly fine. Thank you.

Hi Franklin,

can you please explain how actually the sed search for a pattern wen search is done by grouping. Y the below command is not working ?..
I am bit confused here :confused: ...

sed 's|\(.*[0-9]+\)\(.*[0-9]+\)|\1/\2|' File

how actaully it consider the .* wen it comes to pattern matching.

The metacharacter "+" is available only as part of the extended set used by programs such as egrep and awk.

Regards