Break line after last "/" if length > X characters

Hello.
I am a french newbie in unix shell scripting (sorry if my english speaking is wrong).
I have a file with path and filenames in it. I want to limit the number of characters on each line and break the line if necessary. But the "break" should occur after a slash caracter "/".

Example of input file
/home/xxxx/xxxx/xxxx/xxxx/
/home/xxxx/xxxx/xxxx/xxxx/yyyy/yyyy/yyyy/

Output file (limitation to 33 characters for instance)
/home/xxxx/xxxx/xxxx/xxxx/
/home/xxxx/xxxx/xxxx/xxxx/yyyy/
yyyy/yyyy/

I already managed to do it with a awk script of about 10-12 lines with a while loop and a field separator "/" (sorry I don't have the code here). The thing works but I am sure it could have been done in a more easy and efficient way.

Have you any ideas ? Any help would appreciated.
Thanks.

You can try this if you don't have any spaces in the file:

tr '/' ' ' < file | fold -s -w 33 | tr ' ' '/'

Regards

Thanks for your answer Franklin52.
In fact it is a bit more complicated than that.

My exact input file looks like :

text
text
ASSIGN var1='path/xxx/xxx/xxx/xxx/filename1'
ASSIGN var2='path/yyy/yyy/yyyyyyy/yyyy/y/yyyyyy/yyyy/filename2'
ASSIGN var3='path/zzzzzz/zzzzzzzzzz/zzzzzzzzzzz/filename3'
text
text

I only want to break lines beginning with 'ASSIGN' and with more than 50 characters.

And what should be the desired output (given your sample)?

The output should be :

text
text
ASSIGN var1='path/xxx/xxx/xxx/xxx/filename1'
ASSIGN var2='path/yyy/yyy/yyyyyyy/yyyy/y/yyyyyy/
yyyy/filename2'
ASSIGN var3='path/zzzzzz/zzzzzzzzzz/zzzzzzzzzzz/
filename3'
text
text
sed '/^ASSIGN.\{44\}/s|.\{1,50\}/|&\
|' file

An example (often the embedded new line is not obvious):

bash-2.03$ cat file
text
text
ASSIGN var1='path/xxx/xxx/xxx/xxx/filename1'
ASSIGN var2='path/yyy/yyy/yyyyyyy/yyyy/y/yyyyyy/yyyy/filename2'
ASSIGN var3='path/zzzzzz/zzzzzzzzzz/zzzzzzzzzzz/filename3'
text
text
bash-2.03$ sed '/^ASSIGN.\{44\}/s|.\{1,50\}/|&\
|' file
text
text
ASSIGN var1='path/xxx/xxx/xxx/xxx/filename1'
ASSIGN var2='path/yyy/yyy/yyyyyyy/yyyy/y/yyyyyy/
yyyy/filename2'
ASSIGN var3='path/zzzzzz/zzzzzzzzzz/zzzzzzzzzzz/
filename3'
text
text

Thanks for your answer.
I don't have Unix at home so I cannot test your solution.
I'll test it as soon as i get to work on Monday.

Consider that this command won't wrap the same record more than once.

Thanks Radoulov, it works great !
I have been able to test it on a Linux live CD.

I had tried to do it with sed but i wasn't successfull.
I didn't know the syntax you used.
Does s|.\{1,70\}/| mean that it will match any character until the last / before 70 characters ?

Yes,
it will match from 70 to 1 character(s) followed by slash.