Hi -
I have a file with lots of lines in that I need to order based on the number of commas!
e.g the file looks something like :-
cn=john,cn=users,cn=uk,dc=dot,dc=com
cn=john,cn=users,dc=com
cn=users,cn=groups,dc=com
cn=john,cn=admins,cn=users,cn=uk,dc=dot,dc=com
cn=fred,cn=users,cn=uk,dc=dot,dc=com
cn=simon,cn=users,cn=uk,dc=dot,dc=com
cn=users,dc=com
I need to order the file so that it ends up like :-
cn=john,cn=admins,cn=users,cn=uk,dc=dot,dc=com
cn=john,cn=users,cn=uk,dc=dot,dc=com
cn=fred,cn=users,cn=uk,dc=dot,dc=com
cn=simon,cn=users,cn=uk,dc=dot,dc=com
cn=john,cn=users,dc=com
cn=users,cn=groups,dc=com
cn=users,dc=com
I am hoping someone knows some sed or awk that can do this ?
Many thanks