Path: utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!hplabs!hpda!hpcupt1!hpsal2!morrell From: morrell@hpsal2.HP.COM (Michael Morrell) Newsgroups: comp.unix.questions Subject: Re: Re: sorting and reversing lines of a file Message-ID: <14660007@hpsal2.HP.COM> Date: 28 Feb 89 21:44:23 GMT References: <1774@dlvax2.datlog.co.uk> Organization: HP System Architecture Lab, Cupertino Lines: 33 / hpsal2:comp.unix.questions / leo@philmds.UUCP (Leo de Wit) / 4:00 am Feb 26, 1989 / In article <1774@dlvax2.datlog.co.uk> scm@datlog.co.uk ( Steve Mawer ) writes: [] |Note also that formats such as | | cat file1 file2 > file2 | |will cause your disk to become *very* full (as well as losing the original |contents of file2). Not necessarily so: Script started on Sun Feb 26 12:38:24 1989 philmds> cat /etc/motd Ultrix V2.0-1 System #2: Mon Oct 26 15:31:26 MET 1987 philmds> ls -l file[12] -rw-r----- 1 leo 177 Feb 26 12:37 file1 -rw-r----- 1 leo 273 Feb 26 12:37 file2 philmds> cat file1 file2 >file2 cat: input file2 is output philmds> script done on Sun Feb 26 12:39:11 1989 ---------- Interesting. I never noticed that "cat" would complain if one of its input files was the saem as its output. Unfortunately, although this feature prevents the disk from filling up, it still causes the original contents of file2 to be lost, resulting in file2 being a copy of file1 (at least, this is the behavior on HP-UX). Since the shell is truncating file2 before cat is invoked, you need a smarter shell, not a smarter cat, to avoid this problem. Michael