From owner-freebsd-questions@FreeBSD.ORG Tue Jun 16 13:56:58 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 50FB51065678 for ; Tue, 16 Jun 2009 13:56:58 +0000 (UTC) (envelope-from m2o7i1@gmail.com) Received: from qw-out-2122.google.com (qw-out-2122.google.com [74.125.92.27]) by mx1.freebsd.org (Postfix) with ESMTP id 073078FC12 for ; Tue, 16 Jun 2009 13:56:57 +0000 (UTC) (envelope-from m2o7i1@gmail.com) Received: by qw-out-2122.google.com with SMTP id 3so2183972qwe.7 for ; Tue, 16 Jun 2009 06:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=RtVByUE7oSnHyt1Xdj62+Feebr4dmnqzQ6lO7CgliRs=; b=hn/F+G4YY1cyG1cqDdK84ons5PWftcKseh8PN4KCj4mSSdfB/Sn7EEwOk89SRMXh94 KH9kcNUfyo+BPa/nMJZiDx/FeADS0xCN5I1ebyEbnf6Ge2veonrtJ+6m9dHrYdQFdPYA fgaBPUd4QRoWGbAnaNHt9DkpeNupYF1Z/QB/Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=xn/OePHG3hHrc0I3+DBHYzDemUPu90V4rFfN4PWUXL/i+TuHk3Nk7R5nS0WAq62Ojq T72ByeGXPiF9y7XR6MaP3vxCQvKQF02adHPKOjbOW+5DwntXYizH3us+QFPReW/SRVy4 /Wf2wrTqdO7bHQ4rvotyOIFCJrUNQ/fpTXH+U= MIME-Version: 1.0 Received: by 10.220.76.147 with SMTP id c19mr5550411vck.96.1245159415245; Tue, 16 Jun 2009 06:36:55 -0700 (PDT) In-Reply-To: References: Date: Wed, 17 Jun 2009 09:06:55 +1930 Message-ID: <2620c3260906160636j1f6758fcgafaa6c50811a3452@mail.gmail.com> From: Moises Castellanos To: Carmel NY Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: FreeBSD Questions Subject: Re: Problem with bash script 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: Tue, 16 Jun 2009 13:56:58 -0000 Hi Carmel On Wed, Jun 17, 2009 at 8:39 AM, Carmel NY wrote: > I am attempting to write a simple Bash script that will find all the > '*.pem' files in a directory structure and move them to another > directory. It seems to work until I get to the copy part where it fails. > > My scripting skills are not that good. Perhaps someone could tell me > what I am doing wrong. > > This is the script: > > #! /usr/bin/env bash > > # Save the field separator > oIFS=$IFS > > # Set it to line breaks > IFS=$'\n' > > for i in $(find ./ -name "*.pem" -print); do > > # Get the basename > BN=$(basename $i) > > # copy the file to another directory using the base name > cp $i /usr/home/tmp/$BN > > done > > # Reset the IFS variable > IFS=$oIFS > > exit > > > -- > Carmel > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to " > freebsd-questions-unsubscribe@freebsd.org" > Why you don't use exec flag of find ? You could use: $ find ./ -name "*.pem" -exec cp {} /usr/home/tmp/something \; Regards Moises Castellanos