182 reputation
14
bio website
location
age
visits member for 1 year, 4 months
seen 6 hours ago

2d
accepted How can I print a specific occurence of a range pattern?
2d
comment How can I print a specific occurence of a range pattern?
@ Glenn: Thank you. This is absolutely brilliant! @awk_FTW: You're right and I'll make sure to do it like that from now on.
Apr
21
revised How can I print a specific occurence of a range pattern?
added 193 characters in body
Apr
21
comment How can I print a specific occurence of a range pattern?
@awk_FTW Thanks for the pointers. I updated my question with more information.
Apr
21
comment How can I print a specific occurence of a range pattern?
Thank you very much. Your answer works perfectly for the example I provided. Unfortunately I think that I abstracted my example a bit too much. The real input is delimited by special characters. When I replace the numbers in your script with the (escaped) delimiters it outputs the wrong fields. Is there any chance you could take another look at my edited question?
Apr
21
revised How can I print a specific occurence of a range pattern?
added better example
Apr
21
revised How can I print a specific occurence of a range pattern?
added 140 characters in body
Apr
21
asked How can I print a specific occurence of a range pattern?
Mar
1
accepted How can I delete all unordered lines from a text file?
Feb
27
revised How can I delete all unordered lines from a text file?
edited to be case insensitive
Feb
27
comment How can I delete all unordered lines from a text file?
@HaukeLaging I think this is it (well, almost): ✔ Filters out all unordered elements (in both directions); ✔ is case insensitive (after a small tweak). I am still having some trouble with diacritics, though. awkjust doesn't seem to want to follow canon in how the letters are sorted. E.g.: sort will sort b c d a ä to a ä b c d but if given the latter as an input your snippet removes a. I can only assume that awk isn't registering the locale. It's strange though, because everything else does.
Feb
27
suggested suggested edit on How can I delete all unordered lines from a text file?
Feb
27
revised How can I delete all unordered lines from a text file?
edited to be locale dependent (in accordance with modified question body)
Feb
27
suggested suggested edit on How can I delete all unordered lines from a text file?
Feb
27
comment How can I delete all unordered lines from a text file?
@Grame: Thank you for this script. It works great with different cases and also performs well for different locales and their diacritics. However, it seems to suffer from the same sorting issue as Hauke's awk snippet. E.g: e f g a h i is truncated to e f h i when it should be e f g h i.
Feb
27
comment How can I delete all unordered lines from a text file?
Stephane is right. I am afraid I didn't look at the results thoroughly enough. This script works great if the unordered element in the list is lexicographically lower than the following ordered element (e.g.: j k z l m). OTOH, if the unordered element is lexicographically higher (e.g. e f g a h i) we see the behaviour Stephane pointed out.
Feb
27
comment How can I delete all unordered lines from a text file?
Ah, nervmind. The issue with diacritics was my fault. The first element in the example I linked to ("äpple") should have come after "apple". That's how diacritics are generally sorted in my locale. The issue with different cases remains, though. The items in my list are only sorted alphabetically and without regard to their capitalization. Would it be possible to make awk's sorting case insensitive as well?
Feb
27
comment How can I delete all unordered lines from a text file?
Thanks for your answer! This works great if all elements are lowercase and don't use any special diacritics (as shown in the examples). Unfortunately the phrases I am working with are both upper/lowercase and contain diacritics. This seems to mess the results up. Would it be possible to modify your script to work under these circumstances?
Feb
27
revised How can I delete all unordered lines from a text file?
some more information about the types of phrase we are dealing with
Feb
27
comment How can I delete all unordered lines from a text file?
@StephaneChazelas The decision would have to be made based on the group size. In this scenario ordered elements always come in groups of at least 2. Ccould only be the odd one out if there was an element before A.