sed substitution problem on AIX

I have a file that has one field with this line that I need to change. What I want to have on is turn role/env/proj to ,ou=role,ou=env,ou=proj

#cat file
role/env/proj

I do this on Linux with this command but can't get the \n to work on AIX
#cat file | sed 's/\//\n/g' | sort -r | sed 's/^/,ou=/g' | tr ' \n' ' '


On Linux
#cat /var/run/security-environment | sed 's/\//\n/g'
role
env
proj

On AIX - the \n is ignored a n is put in. Have tried various things but nothing works.
cat file | sed 's/\//\n/g'
rolenvnproj
lolaferrariAsked:
Who is Participating?
 
woolmilkporcCommented:
AIX's sed does not understand these backslash escapes.

Try awk:

awk -F/ '{for(i=1;i<NF;i++) printf ",ou=%s", $i; print ",ou=" $i}' file

... or install GNU sed from the AIX toolbox or from http://www.perzl.org/aix
0
 
ozoCommented:
have you tried
sed 's/\//
/g'
0
 
lolaferrariAuthor Commented:
Fantastic! Many thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.