Searching for visible and invisible system files gives no results [duplicate]

Though, it won't update the results in spotlight I use the below script to toggle hidden files on and off every time it's run:

To make:

  • Open TextEdit
  • Make sure it is in Plain Text Mode (Format > Make Plain Text from the menu)
  • paste in the below text:
    #Load current state into I
    I=$(defaults read com.apple.Finder AppleShowAllFiles)
    if [ "$I" == "false" ]
      then
        # Flip
        I=true
        echo -e "\t>> Showing Hidden Files"
      else 
        # Flop
        I=false
        echo -e "\t<< Hiding Hidden Files"
    fi
    # Write I to com.apple.Finder.plist
    defaults write com.apple.Finder AppleShowAllFiles $I
    # Restart Finder
    killall Finder
    exit
  • Save the above file to your desktop as togglehidden.command (be sure not to append .txt to the end of the file)
  • Open /Applications/Utilities/Terminal
  • Enter the command chmod u+x ~/Desktop/togglehidden.command to make your new file executable.
  • Double Click togglehidden.command on your desktop to show or hide hidden files.