Script to collect a list of a specific folders contents?

Contributor II

I was wondering if there is a script out there I could utilise, to list the file contents of
the users /library/LaunchDaemons /library/LaunchAgents /library/StartupItems

So that I can keep the startup items of users devices to a minimum, I hope to collect a list of plist files that don't need to be set for startup.


New Contributor III

You could do something as simple as follows:


ls /Library/LaunchDaemons > "Filename/Location" &&
ls /Library/LaunchAgents >> "Filename/Location" &&
ls /Library/StartupItems >> "Filename/Location"

This will collect the data from the command and put it to a text file if you name the file something like "dataoutput.txt" and you can specify save location too such as "/Users/$USER/Desktop/dataoutput.txt".

New Contributor III

I have the exact same question, though more specifically, I'd like to create an extension attribute which lists the contents of /Library/LaunchAgents, /Library/LaunchDaemons, /Library/Startupitems AND their counterparts in ~/Library. My intent is to use this data to look for the presence of Malware.