![]() UPDATE: In the comments, Jonathan Leffler says that even though word boundary ( \b) is in Mac regex docs, Mac sed doesn't seem to recognize it. If you have version numbers over 99 but less than 1000, the command gets only slightly more complicated: sed 's/\b\(\)\b/00\1/g s/\b\(\)\b/0\1/g' versions.txt | sort | sed 's/\b0\ \(\)/\1/g'Īs I don't have a Mac, the above were tested on Linux. The works as long as version numbers are 99 or less. In the full command, the last sed command removes the leading zeros to produce the final output: 6.3.1.1 After that, it is a matter of removing the added characters. With your input as versions.txt, the first sed command adds a leading zero onto single-digit version numbers, producing: 06.03.01.01 To explain why this works, consider the first sed command by itself.
0 Comments
Leave a Reply. |