on-internet
← Community

Move file only if it exists

Stack Overflow ·

I want to use mv to rename a file: mv src.txt dest.txt If the file doesn't exist, I get an error: mv: cannot stat ‘src.txt’: No such file or directory How do I use mv only if the file already exists? I don't want to redirect stderr to dev/null as I'd like to keep any other errors that occur

Comments

Sign in or sign up to comment and upvote.

No comments yet.