![]() '/^Application 2021:/,/^Version:/ - find range of lines where first line starts with Application 2021: and last line starts with Version: (literal period after the 16).One sed idea: $ sed -En '/^Application 2021:/,/^Version:/ s/^Version: *\.(+).*/\1/p' suppress default behavior of printing pattern space of the remaining textĪssuming there will only be one set of lines that match Application 2021: and Version: V=$(system_profiler SPApplicationsDataType | fgrep -A 2 ' Adobe InDesign 2021') # then use fgrep to pull out the line, and the 2 lines after, that starts with Adobe InDesign 2021 # Ask system_profiler for information about all the installed applications Here is the final script, utilizing the solution I chose: #!/bin/bash This could work for any situation where you needed to know an application's version number. 16.3 and above require different behavior in the remainder of the script. ![]() The background is I need to find the exact version of Adobe InDesign a user has on their system. Thanks to Paul Hodges for his concise answer. I have tried many things from various answers around the web that seem related, without success.įor example, the closest I got was using the regex (?:\b16\.)(\d) works to find 16.3 on regexr but I hadn't figured out how to capture just the 3 (probably easy if I knew regex better). ![]() I only need to capture the second part of the 2021 version that starts with 16 ( 3 in this case) and test if it's 3 or greater. ![]() ![]() Here is some example text, stored in a variable called myinfo: Application 2021: I am attempting to parse some data in a bash script and test the second part of a version number. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |