From owner-freebsd-questions Tue Dec 15 10:24:12 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA02654 for freebsd-questions-outgoing; Tue, 15 Dec 1998 10:24:12 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from pau-amma.whistle.com (s205m64.whistle.com [207.76.205.64]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA02634 for ; Tue, 15 Dec 1998 10:24:07 -0800 (PST) (envelope-from dhw@whistle.com) Received: (from dhw@localhost) by pau-amma.whistle.com (8.9.1/8.9.1) id KAA08906; Tue, 15 Dec 1998 10:22:19 -0800 (PST) (envelope-from dhw) Date: Tue, 15 Dec 1998 10:22:19 -0800 (PST) From: David Wolfskill Message-Id: <199812151822.KAA08906@pau-amma.whistle.com> To: empey@integral.on.ca, freebsd-questions@FreeBSD.ORG Subject: Re: Two Questions In-Reply-To: <199812150423.XAA12491@integral.on.ca> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >Date: Mon, 14 Dec 1998 23:23:59 -0500 >From: David Empey >First, I need to be able to change the extension on a large number of files >in a directory from *.txt to *.ltr, but I cannot seem to get the mv (or >the cp and rm) commands to do the job. Is there something easier to do >than renaming the files one by one? As someone else pointed out, there are shell-specific ways to implement looping constructs to accomplish such things. Another approach (that I use about as often) is to fire up "vi" on a nonexistent file, then use combinations of shell escapes and regex substitutions to fabricate a list of the commands that I would want to be executed, then enter a sequence to feed the current edit buffer to the shell. For example: cd /some/directory vi foo [within vi, now....] !!ls *.txt :%s/^\(.*\).txt/mv \1.txt \1.ltr/ [review the list of commands....] 1G!Gsh :q! [all done....] david -- David Wolfskill UNIX System Administrator dhw@whistle.com voice: (650) 577-7158 pager: (650) 371-4621 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message