Sorry, I just noticed that the one-liner posted above will work only if, within the double-brackets:
(a) there's a single string with no embedded "|"s
(b) there are exactly two strings with exactly one embedded "|"
So, cases like the following:
[[abc|def|ghi]]
[[abc|def|ghi|jkl]]
will not be matched, and hence will not be altered by the script.
An example follows (I've modified your data a bit):
$
$
$ cat f8
There are many types and traditions of anarchism, some of which are [[mutually exclusive]].
Strains of anarchism have been divided into the categories of [[social anarchism|social]]
and [[individualist anarchism]] or similar dual classifications. Anarchism is often
considered to be a radical [[left-wing]] ideology, and much of [[anarchist economics]]
and [[anarchist law|anarchist legal philosophy]] reflect [[anti-statism|anti-statist|non-statist]]
interpretations of [[anarcho-communism|communism]], [[collectivist anarchism|collectivism]],
[[anarcho-syndicalism|syndicalism|blah|BLAH]] or [[participatory economics]].
$
$
$ # Old script that does NOT work for more than 2 delimited tokens within double-brackets
$ perl -plne 's/\[\[[^|]*?\|*([^|]*?)\]\]/$1/g' f8
There are many types and traditions of anarchism, some of which are mutually exclusive.
Strains of anarchism have been divided into the categories of social
and individualist anarchism or similar dual classifications. Anarchism is often
considered to be a radical left-wing ideology, and much of anarchist economics
and anarchist legal philosophy reflect [[anti-statism|anti-statist|non-statist]]
interpretations of communism, collectivism,
[[anarcho-syndicalism|syndicalism|blah|BLAH]] or participatory economics.
$
$
The fix for this is to modify the regex so that it:
(a) matches all characters, including "|"s, as much as possible
(b) matches a single "|" character (if it exists at all)
(c) matches the remainder that does not include "|", and set it to position 1
Something like this:
$
$ cat f8
There are many types and traditions of anarchism, some of which are [[mutually exclusive]].
Strains of anarchism have been divided into the categories of [[social anarchism|social]]
and [[individualist anarchism]] or similar dual classifications. Anarchism is often
considered to be a radical [[left-wing]] ideology, and much of [[anarchist economics]]
and [[anarchist law|anarchist legal philosophy]] reflect [[anti-statism|anti-statist|non-statist]]
interpretations of [[anarcho-communism|communism]], [[collectivist anarchism|collectivism]],
[[anarcho-syndicalism|syndicalism|blah|BLAH]] or [[participatory economics]].
$
$ # New script that should work
$ perl -plne 's/\[\[.*?\|*([^|]*?)\]\]/$1/g' f8
There are many types and traditions of anarchism, some of which are mutually exclusive.
Strains of anarchism have been divided into the categories of social
and individualist anarchism or similar dual classifications. Anarchism is often
considered to be a radical left-wing ideology, and much of anarchist economics
and anarchist legal philosophy reflect non-statist
interpretations of communism, collectivism,
BLAH or participatory economics.
$
$
tyler_durden