I have a file that has one entry per line. Each line has the following format:
'group:permissions:users'
Permissions and users could have more than one value separated by comas like this:
'grp1:create,delete:yo,el,ella'
I want is to return the following:
yo el ella
This is what I have so far:
cat file | grep grp1 -w | cut -f3 -d: | cut -d ',' -f 2
This returns yo,el.ella, How can I make it return one value per line?
You can use awk, with the -F option to use : as the field separator:
That will get you just the users string, separated by commas. Then you can do whatever you want with that string. If you want to literally print each user one per line, you could use tr to replace the commas with newlines: