Based on the following lines entries...how do we identify similiarities (up to a number of characters or up to a number of delimiters, or something else), and then say "these lines all have similar characters except for the last delimited characters, so we will merge all these lines into a single line of only the similiar characters)...i hope that makes sense.
http-myline-hostname38
http-myline-hostname58
http-myline
http-myline-secure-hostname37
http-myline-secure-hostname28
http-myline-person-hostnameBZ
http-myline-person-hostnameAB
resulting in the following entries:
http-myline
http-myline-secure
http-myline-person
Try:
awk NF-=1 FS=- OFS=- infile | sort -u
sed 's/-[^-]*$//' infile | sort -u
1 Like
Thank you.
I should have added more specific input lines, i will do so here.
From:
http-myline-hostname38
http-myline-hostname58
http-myline87
http-file
http-blob
http-para
http-lab
http-myline-secure-hostname37
http-myline-secure-hostname28
http-myline-person-hostnameBZ
http-myline-person-hostnameAB
http-may-server400
http-feb-server500-keep
http-april-server700-abcd-devel
And the desired output is to only merge and collapse lines that are similar up to a designated number of characters (say 10 or 20, depending).
So the desired output will be:
http-myline
http-myline87
http-file
http-blob
http-para
http-lab
http-myline-secure
http-myline-person
http-may-server400
http-feb-server500-keep
http-april-server700-abcd-devel