From owner-freebsd-questions@FreeBSD.ORG Sun Jan 15 17:54:31 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A47A916A41F for ; Sun, 15 Jan 2006 17:54:31 +0000 (GMT) (envelope-from matze@matzsoft.de) Received: from ds80-237-203-117.dedicated.hosteurope.de (ds80-237-203-117.dedicated.hosteurope.de [80.237.203.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id C221C43D45 for ; Sun, 15 Jan 2006 17:54:30 +0000 (GMT) (envelope-from matze@matzsoft.de) Received: (qmail 88933 invoked from network); 15 Jan 2006 17:50:27 -0000 Received: from unknown (HELO ?192.168.0.4?) (matze@mausland-entertainment.com@85.182.75.3) by 0 with AES256-SHA encrypted SMTP; 15 Jan 2006 17:50:27 -0000 Message-ID: <43CA8DD1.5070202@matzsoft.de> Date: Sun, 15 Jan 2006 19:00:49 +0100 From: Mathias Menzel-Nielsen User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050624) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ronny Hippler References: <43C9FB5A.2050506@yahoo.com> In-Reply-To: <43C9FB5A.2050506@yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd questions Subject: Re: shell scripts and escaped charecters in file names X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jan 2006 17:54:31 -0000 Ronny Hippler wrote: > Hello, > I am trying to get the following script to run with no success. > - ------------------------------------ > #!/bin/csh > foreach file (\*vol\*) > mv $file `basename $file .par2`.PAR2 > echo $file > end > - ------------------------------------ > and get the following error: > usage: mv [-f | -i | -n] [-v] source target > ~ mv [-f | -i | -n] [-v] source ... directory > > I know it is because of the spaces and such in the file names. I have > tried quoting single double and also escaping them but all fails. what > is the magic? Please cc me off list. thanks! Hi. Sorry, dont know the trick for csh -- but for bash there is an env, which can be used to override word-split whitespaces: IFS (see bash(1)) The following script should do the trick (i have tested it with some filenames with spaces in it succesfully): 8<----8<----8<---- #!/bin/sh IFS=" " export IFS; for i in *; do mv $i `basename $i .par2`.PAR2; echo $i; done; 8<----8<----8<----8< note how IFS is set to newline (replace the *-wildchar in the for-line with your fileset) Hope it helps greetings, Mathias