Find all files with the name ".txt" in the Desktop directory, sort them randomly, take the first one, and replace all occurrences of "red" with "blue".
find ~/Desktop -iname ".txt" | sort -R | head -n1 | xargs sed -i 's/red/blue/'