April 26, 2019

Getting Rid of Nasty Adobe Flash Cookies the Cool Linux Way - page 2

Using find to See What We're Up Against

  • March 27, 2009
  • By Carla Schroder

Once you verify that you have a batch of Flash cookies, find will find and delete them all in one command by using the powerful -exec option, like this:

$ find -iname '*.sol' -exec rm "{}" \;

This means "find all files with the extension .sol and delete them." rm is remove, or delete. "{}" means "replace me with the name of the current file being processed", and the semi-colon means "stop, there are no more commands to execute." The semi-colon must be escaped with the backslash because it has a special meaning to the Bash shell, and we don't want Bash mucking with it.

find is very fast and this will nuke all Flash cookies in an eyeblink. If you're nervous, you can use -ok instead of -exec and you'll be asked to verify each deletion:

$ find -iname '*.sol' -ok rm "{}" \;
$ < rm ... ./s_br.sol > ?

Type y for yes or n for no.

Fun With find and xargs: Sort Flash Cookies By Date

Maybe you want to see your listing of Flash cookies sorted by date. Your first impulse might be to use -exec

again, like this:

$ find -iname '*.sol' -exec ls -l "{}" \;

But this won't work, because the -exec option processes one file at a time, so one file at a time will be sent to ls. We want all of the output of find sent in one batch to ls, which is a job for pipes and the xargs command, like this:

$ find -iname '*.sol' | xargs ls -lt

xargs is another endlessly useful command that takes the output of another command and lets you run other commands on it. You can do more than simply view your Flash cookies in date order; see man xargs for inspiration.

Most Popular LinuxPlanet Stories