File: copy-if-change

package info (click to toggle)
r-base 2.1.0-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 43,944 kB
  • ctags: 23,283
  • sloc: ansic: 200,913; fortran: 68,557; sh: 12,127; perl: 8,510; makefile: 5,810; tcl: 2,953; yacc: 2,077; java: 455; asm: 268; sed: 16
file content (14 lines) | stat: -rwxr-xr-x 259 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh
#
# Like cp $1 $2, but if the files are the same, do NOTHING.
# Status is 0 if $2 is changed, 1 otherwise.

if test -r "$2"; then
  if cmp "$1" "$2" > /dev/null; then
    echo "$2" is unchanged
  else
    cp -f "$1" "$2"
  fi
else
  cp "$1" "$2"
fi