How to redirect output to a file only if it exists?

This is the opposite of the clobber / noclobber function. I only want to update the file if it already exists. I know I can do this with a few commands, but does he have one statement?

+3
source share
2 answers

I RTFMed and operator does not exist yet.

0
source

Closest I can think of [[ -f "$filename" ]] && do something > "$filename"

+3
source

All Articles