~johanvandegriff/unix-shell-programming-revised-edition-programs

unix-shell-programming-revised-edition-programs/save.sh -rw-r--r-- 341 bytes
fc214385Johan Vandegriff added other old scripts, some newer ones too 1 year, 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
from="$1"
to="$2"
all=`ls "$to"`
if [ "$3" == "-r" ]
then
  name=`echo "$all" | tail -1`
  echo "$name"
  sudo cp "$to/$name" "$from"
else
  if [ -z "$all" ]
  then
    name="0000000000"
  else
    name=`echo "$all" | tail -1 | awk '{print $0 + 1}'`
    name=`printf "%10s" "$name" | tr ' ' '0'`
  fi
  cp "$from" "$to/$name"
fi