Литмир - Электронная Библиотека
Содержание  
A
A

 } else

  *pto1 = *pfrom1;

 *pcmd = *s++;

 a2i(*pfrom2);

 if (*s == ',') {

  s++;

  a2i(*pto2);

 } else

  *pto2 = *pfrom2;

}

nskip(fin, n) /* skip n lines of file fin */

 FILE *fin;

{

 char buf[BUFSIZ];

 while (n-- > 0)

  fgets(buf, sizeof buf, fin);

}

ncopy(fin, n, fout) /* copy n lines from fin to fout */

 FILE *fin, *fout;

{

 char buf[BUFSIZ];

 while (n-- > 0) {

  if (fgets(buf, sizeof buf, fin) == NULL)

   return;

  fputs(buf, fout);

 }

}

#include "efopen.c"

3.8.28

makefile

files: files.o files1.o directory.o

      cc files.o files1.o directory.o -o files

p0: p0.c ttyin0.c

      cc p0.c ttyin0.c

clean:

      rm -f *.o a.out

3.8.29

newer

# newer f: list files newer than f

ls -t | sed '/^'$1'$/q'

3.8.30

news1

# news: print news files, version 1

HOME=. # debugging only

cd . # place holder for /usr/news

for i in `ls -t * $HOME/.news_time`

do

 case $i in

 */.news_time) break ;;

 *) echo news: $i

 esac

done

touch $HOME/.news_time

3.8.31

news2

# news: print news files, version 2

HOME=. # debugging only

cd . # place holder for /usr/news

IFS='

' # just a newline

for i in `ls -t * $HOME/.news_time 2>&1`

do

case $i in

*' not found') ;;

*/.news_time) break ;;

*) echo news: $i ;;

esac

done

touch $HOME/.news_time

3.8.32

news3

# news: print news files, final version

PATH=/bin:/usr/bin

IFS='

' # just a newline

cd /usr/news

for i in `ls -t * $HOME/.news_time 2>&1`

do

 IFS=' '

 case $i in

 *' not found') ;;

 */.news_time) break ;;

 *) set X`ls -l $i`

  echo "

$i: ($3) $5 $6 $7

"

  cat $i

 esac

done

touch $HOME/.news_time

3.8.33

nohup

trap "" 1 15

if test -t 2>&1

then

 echo "Sending output to 'nohup.out'"

 exec nice -5 $* >>nohup.out 2>&1

else

 exec nice -5 $* 2>&1

fi

3.8.34

older

# older f: list files older than f

ls -tr | sed '/^'$!'$/q'

3.8.35

overwrite1

# overwrite: copy standard input to output after EOF

# version 1. BUG here

PATH=/bin:/usr/bin

case $# in

1) ;;

*) echo 'Usage: overwrite file' 1>&2; exit 2

esac

new=/tmp/overwr.$$

trap 'rm -f $new; exit 1' 1 2 15

178
{"b":"248117","o":1}