Initial release

This commit is contained in:
hjp 2000-08-23 13:03:42 +00:00
parent 989af92d7b
commit 94d4248916
4 changed files with 95 additions and 0 deletions

25
truncate/GNUmakefile Normal file
View File

@ -0,0 +1,25 @@
include GNUmakevars
all: truncate
clean:
rm truncate customize
install: $(BINDIR) $(BINDIR)/truncate $(MAN1DIR)/truncate.1
%: %.pl customize
sh ./customize < $< > $@
chmod +x $@
%: %.sh customize
sh ./customize < $< > $@
chmod +x $@
customize: configure
sh ./configure
$(BINDIR):
mkdir -p $@
include GNUmakerules

40
truncate/configure vendored Normal file
View File

@ -0,0 +1,40 @@
#!/bin/sh
#
echo "#!/bin/sh" > customize.$$
echo "sed \\" > customize.$$
chmod +x customize.$$
################################################################
# find a find which understands -printf
# (like gnu find)
#
now=`date '+%Y%m%d' `
touch find_printf.$now.$$
for i in /usr/bin/find /usr/local/bin/find
do
ts=`$i find_printf.$now.$$ -printf '%TY%Tm%Td\n'`
if [ "x$ts" = "x$now" ]
then
echo $i works
find_printf="$i"
break
fi
done
if [ -z "$find_printf" ]
then
echo could not find a working find_printf command, sorry.
exit 1
fi
echo " -e 's,@@@find_printf@@@,$find_printf,g' \\" >> customize.$$
rm find_printf.$now.$$
################################################################
# finish
# Add trailing newline and rename temp file to final name
#
echo >> customize.$$
mv customize.$$ customize

23
truncate/truncate.1 Normal file
View File

@ -0,0 +1,23 @@
.\" $Id: truncate.1,v 1.1 2000-08-23 13:03:42 hjp Exp $
.\" $Log: truncate.1,v $
.\" Revision 1.1 2000-08-23 13:03:42 hjp
.\" Initial release
.\"
.\"
.TH truncate 1
.SH NAME
truncate - truncate files to zero length
.SH SYNOPSIS
.B truncate
[
.I find-options
]
.SH DESCRIPTION
Truncate uses find with the specified options to find regular files.
Each file is truncated to zero length, but owner, permissions, and
last-modified date are preserved. If the user doesn't have write
permissions for a file, a message is printed and the file is skipped.
.SH DIAGNOSTICS
Various error messages from the used commands.
.SH AUTHOR
Peter J. Holzer (hjp@wsr.ac.at)

7
truncate/truncate.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/sh
@@@find_printf@@@ "$@" -type f -printf '%TY%Tm%Td%TH%TM.%TS %p\n' |
while read timestamp file
do
echo > "$file"
touch -t "$timestamp" "$file"
done