[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1013
  • Last Modified:

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
0
lolaferrari
Asked:
lolaferrari
1 Solution
 
ozoCommented:
have you tried
sed 's/\//
/g'
0
 
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
 
lolaferrariAuthor Commented:
Fantastic! Many thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now