From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from minnie.tuhs.org (minnie.tuhs.org [45.79.103.53]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 3ec7866d for ; Thu, 5 Mar 2020 22:23:58 +0000 (UTC) Received: by minnie.tuhs.org (Postfix, from userid 112) id C74499D78D; Fri, 6 Mar 2020 08:23:55 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 4F28F9D777; Fri, 6 Mar 2020 08:23:30 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=pass (2048-bit key; unprotected) header.d=aueb.gr header.i=@aueb.gr header.b="SbkCNDEF"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 674139D777; Fri, 6 Mar 2020 08:23:27 +1000 (AEST) X-Greylist: delayed 368 seconds by postgrey-1.36 at minnie.tuhs.org; Fri, 06 Mar 2020 08:23:25 AEST Received: from blade-b3-vm-relay.servers.aueb.gr (blade-b3-vm-relay.servers.aueb.gr [195.251.255.106]) by minnie.tuhs.org (Postfix) with ESMTP id D03789D698 for ; Fri, 6 Mar 2020 08:23:25 +1000 (AEST) Received: from blade-a1-vm-smtp.servers.aueb.gr (blade-a1-vm-smtp.servers.aueb.gr [195.251.255.217]) by blade-b3-vm-relay.servers.aueb.gr (Postfix) with ESMTP id 72974B3B for ; Fri, 6 Mar 2020 00:17:15 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aueb.gr; s=201901; t=1583446635; bh=DW1n6+SpDkhnDkSW1Nr9r7p+dkGw+jj/C+9JD0FFIfs=; h=Subject:To:References:From:Date:In-Reply-To:From; b=SbkCNDEFCGM/ff8DZHrolD/iyTy2sAiloznsKsR2gC0iOxpZvFu3eeF6g4VbusfBM HtjYkOTTvwd5ZlHRJHYUrpHaLgTL6+rMEdTn1xd2gORa+hNb5tal8kHtcdUHDBf+7s BRM+hHEvNLfmdkamZ330kEcLbVzeDqwW2OWlLvdbliqkWRrKS5edqzkfllNvBiAa5W C5fV53/UuVut/w8EUWC3ZCv4UqPp8bLIEnNnmbf5I8syvQMGW4yVTQyls9hfGUzy6N /MCgCwOLt4lZMs1ag4qApSO3YRK8IiC37YEKUHq5qshNRC4FBibNTrsjDGfe7DfF0/ nHTIgxVNoThjg== Received: from [192.168.136.3] (ppp-2-84-110-239.home.otenet.gr [2.84.110.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dds) by blade-a1-vm-smtp.servers.aueb.gr (Postfix) with ESMTPSA id 3BF988CC for ; Fri, 6 Mar 2020 00:17:14 +0200 (EET) To: tuhs@tuhs.org References: <202003050457.0254vJ2Y142485@tahoe.cs.Dartmouth.EDU> From: Diomidis Spinellis Phone: +30 210 8203621 Message-ID: <16a4760f-7bab-c36a-4df7-1df6fc40694d@aueb.gr> Date: Fri, 6 Mar 2020 00:17:15 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <202003050457.0254vJ2Y142485@tahoe.cs.Dartmouth.EDU> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: el Content-Transfer-Encoding: 7bit Subject: Re: [TUHS] Command line options and complexity X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" On 05-Mar-20 6:57, Doug McIlroy wrote: >> These go all the way back to v7 unix, where ls has an option to reverse > the sort order (which could have been done by passing the output to tac). > > A cool idea, but tac was not in v7. And tail didn't get the -r > option until v8. Tail acquired a -r option between 3BSD [1] and 4BSD [2]. I remember using that option on SunOS in 1990 as part of a prank we played on a friend at the university. On the Sun 3 workstations we were using at the time, one could enter the monitor/debugger program by pressing L1-A. By remotely logging into a workstation and running a shell loop, one could ensure that when the monitor was entered the active program would be that shell. It was then easy to modify the uid field for the active process (the loop-running shell) and set it to zero. After exiting the monitor, a subshell launched from that shell would have full root privileges. All we had to do was wait for the friend to lock his workstation when taking a break in order to obtain root privileges on his workstation and then change to his uid in order to modify his files via NFS on the university's Gould file server. Based on this capability, I wrote the following script that would rename all our friend's files and directories to words from the dictionary. The script also created (via tail -r) another script that would undo this change. #!/bin/sh TMP=/tmp DIR=$1 FILES=$TMP/f.$$ WORDS=$TMP/w.$$ CMD=$TMP/c.$$ REV=$TMP/r.$$ trap '' 0 1 2 3 15 find $DIR -depth -print >$FILES head -`wc -l <$FILES|sed 's/[ ]*//'` /usr/dict/words >$WORDS paste $FILES $WORDS | sed -e ' /^\. /d s/\(.*\)\/\(.*\) \(.*\)/mv \1\/\2 \1\/\3/ ' >$CMD rm $FILES $WORDS tail -r $CMD | sed -e ' s/mv \(.*\) \(.*\)/mv \2 \1/ ' >$REV sh <$CMD rm $CMD Unfortunately, it turned out that tail -r had a limit on the number of lines it could reverse. Although the script and its undo worked fine on a test set of a small number of files, when run on our friend's directory it created a faulty undo script. Our friend ended up graduating with files named "abaca" and "abacinate". [1] https://dspinellis.github.io/manview/?src=https%3A%2F%2Fraw.githubusercontent.com%2Fdspinellis%2Funix-history-repo%2FBSD-3%2Fusr%2Fman%2Fman1%2Ftail.1&name=BSD%203%3A%20tail(1)&link=https%3A%2F%2Fgithub.com%2Fdspinellis%2Funix-history-repo%2Fblob%2FBSD-3%2Fusr%2Fman%2Fman1%2Ftail.1 [2] https://dspinellis.github.io/manview/?src=https%3A%2F%2Fraw.githubusercontent.com%2Fdspinellis%2Funix-history-repo%2FBSD-4%2Fusr%2Fman%2Fman1%2Ftail.1&name=BSD%204%3A%20tail(1)&link=https%3A%2F%2Fgithub.com%2Fdspinellis%2Funix-history-repo%2Fblob%2FBSD-4%2Fusr%2Fman%2Fman1%2Ftail.1 -- Diomidis Spinellis Free edX MOOC on Unix Tools: Data, Software, and Production Engineering https://www.spinellis.gr/unix?tuhs20200306