App icon from command line

Contributor II

I am looking for a command line way to extract the icon from an app. Any ideas? Apps in Big Sur do not necessarily have an icns file in the app bundle. (I’m looking at you System Preferences)


Contributor III

If you are looking for a "one-off" copy of icons a quick way would be:
Create a folder /tmp/myIcons
Then try to get all icons

find /  -name "*.icns" -exec cp '{}' "/tmp/myIcons" ;

A few prompts to "Allow" later and you should have some 1000 files.
Looking for System and I found 'SystemPrefApp.icns'

A second find and we can get the path to that file.

find / -name "SystemPrefApp.icns"

No a nice way but could be a starting point.