Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Dec 2002 20:57:29 +0200
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Dan Malaby <dan@peritek.com>
Cc:        questions@FreeBSD.ORG
Subject:   Re: OT: shell questions
Message-ID:  <20021210185729.GN1454@gothmog.gr>
In-Reply-To: <5.1.0.14.2.20021210084343.00aa3228@pop3.peritek.com>
References:  <5.1.0.14.2.20021210084343.00aa3228@pop3.peritek.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2002-12-10 09:08, Dan Malaby <dan@peritek.com> wrote:
> I have a 4.7 FBSD with samba running, so I get a lot of files with
> unkosher names ie.  spaces in the name. So what I tried doing was to
> write a shell script using sh that located these files and changed the
> space to a underbar.
>
> I know that if I, from the keyboard, put quotes around the offending
> name, that I can mv the file to a new name. So I wrote a shell script
> using awk and sed to make a file with the offending names with quotes
> around them. Then I tried to feed this into another script that was
> going to do the actually mv.

One possible answer is to write an awk script that generates the
proper commands for sh(1) and feeds them down a pipe.  Something like:

	find . -name '* *' | awk '{
		name=$0;
		gsub(" ","_",name);
		printf "echo mv \"%s\" \"%s\"\n", $0, name;
	}' | sh

As shown above the script will only echo the commands that sh(1) would
execute, but not really do anything else.  Replace the 'echo mv'
command with 'mv' and you're set to go :)

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?20021210185729.GN1454>