From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8846 invoked by alias); 17 Aug 2015 01:57:07 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20422 Received: (qmail 27444 invoked from network); 17 Aug 2015 01:57:05 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,HTML_MESSAGE autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=YWpBZ7g/YkVawLUg4aX4n+v5u8KGI6s/Pg519xo4gAA=; b=YfukV6+8gDqvHJJEv5mchZ5gH5SFN0fV4Rnrivi3fy/zW9gq57GFxhFlO6MX0RU7Tz XKYO9tvQlyNT0GCopTJT0ClsEd4kZE5rDL0xsjtRcPVjhXb9X/4/4pJUkgq4bMZDhz6w TNVMCv4OfFLd1rJmR49H83q+9aduB4+1CXTcbsU+eZuT/Pr5TniNqkuSEx95Pu2QbSTL XcRiM08ti8P3uKdN8r3KyUIipqMDCWR3tQEay8bS/OO1muJl9dYKyIXUe0OAZGDCq7+S 3rw1vPyhk5SP1BRx/aPt1jJk0lz/caL+9TQaJu5hMMf7bXdr1yEM4v2f1tWlb/dwHA7i eetA== X-Gm-Message-State: ALoCoQkr9dsHwlT27CjODC6jJzViZQlnddHlE+Vq8qqzq/LJtLOjI/xCusnAgtuSUF359lEYqzbB MIME-Version: 1.0 X-Received: by 10.112.156.168 with SMTP id wf8mr53731569lbb.114.1439776622978; Sun, 16 Aug 2015 18:57:02 -0700 (PDT) In-Reply-To: <87r3n2dav7.fsf@nl106-137-147.student.uu.se> References: <87r3n2dav7.fsf@nl106-137-147.student.uu.se> Date: Sun, 16 Aug 2015 18:57:02 -0700 Message-ID: Subject: Re: translate all sequences of whitespace/underscores to single dashes From: Kurtis Rader To: Zsh Users Content-Type: multipart/alternative; boundary=001a11c33f6e2b4283051d781ea3 --001a11c33f6e2b4283051d781ea3 Content-Type: text/plain; charset=UTF-8 On Sun, Aug 16, 2015 at 5:20 PM, Emanuel Berg wrote: > How can I do this directly and only in zsh, i.e. > not using tr (translate characters)? > > # whitespace(s) and underscore(s) -> (a single) dash > new_name=${new_name//[_ ]/-} > new_name=`echo $new_name | tr -s "-"` > The patterns are the same as those for filename generation (so see that section of "man zshexpn"). The solution is to enable extended_glob support. # setopt extendedglob # x='a b_c_ d' # print ${x//[_ ]##/-} a-b-c-d -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank --001a11c33f6e2b4283051d781ea3--