Поскольку порядок может меняться, это немного сложнее, но sed может справиться с этим:
s/\[(.*)\](\/segment\?)(.*)/\3,\1/ #Match text between [], append to end of line and remove /segmennt?
s/city=([^&,]*)[&,](.*)/\2,\1/ #Match city= followed by any character
s/language=([^&,]*)[&,](.*)/\2,\1/ #except & and , which are the separators and append to end of line
s/x=([^&,]*)[&,](.*)/\2,\1/
s/\by=([^&,]*)[&,](.*)/\2,\1/ #Avoid matching city again by making sure y is at a word boundary
s/z=([^&,]*)[&,](.*)/\2,\1/
Запуск от имени: sed -rnf scriptfile inputfile