File: cp_if_different.sh

package info (click to toggle)
isl 0.27-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,476 kB
  • sloc: ansic: 230,339; python: 19,348; cpp: 7,165; sh: 4,701; makefile: 767; lisp: 207; perl: 9
file content (10 lines) | stat: -rwxr-xr-x 179 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
#/bin/sh
# Copy $SRC to $DST unless $DST already exists and has the same contents.
SRC="$1"
DST="$2"

if cmp -s "$SRC" "$DST" 2>/dev/null; then
    :
else
    cp "$SRC" "$DST"
fi