move only if file exists in a shell script move only if file exists in a shell script linux linux

move only if file exists in a shell script


One-liner:

[ -f old ] && mv old nu


You should test if the file exists

if [ -f blah ]; then   mv blah destinationfi


This one liner returns successfully even if the file is not found:

[ ! -f src ] || mv src dest