Date: Tue, 15 Dec 1998 10:22:19 -0800 (PST) From: David Wolfskill <dhw@whistle.com> To: empey@integral.on.ca, freebsd-questions@FreeBSD.ORG Subject: Re: Two Questions Message-ID: <199812151822.KAA08906@pau-amma.whistle.com> In-Reply-To: <199812150423.XAA12491@integral.on.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
>Date: Mon, 14 Dec 1998 23:23:59 -0500 >From: David Empey <empey@integral.on.ca> >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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199812151822.KAA08906>