'Validate language code for Wikimedia languages [closed]

I have a shell script that uses Wikidata Query Service (WDQS) to get required data. The SPARQL query that run WDQS takes input parameter language code.

Is there a way that I can check in shell script if the input language code is a valid Wikimedia language code as the first column data in below link https://www.wikidata.org/wiki/Help:Wikimedia_language_codes/lists/all



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source