sed substitution problem on AIX

Posted on 2012-08-30
Last Modified: 2012-08-31
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

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'

On AIX - the \n is ignored a n is put in. Have tried various things but nothing works.
cat file | sed 's/\//\n/g'
Question by:lolaferrari
    LVL 84

    Expert Comment

    have you tried
    sed 's/\//
    LVL 68

    Accepted Solution

    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

    Author Closing Comment

    Fantastic! Many thanks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Suggested Solutions

    Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
    My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (, discussed installing the Solaris Operating S…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    Video by: Phil
    This video goes over how to configure and start a jail in FreeBSD.  This video is meant to supplement the article included with this course.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now