From owner-freebsd-questions@freebsd.org Wed Feb 3 03:47:11 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 12171A732DE for ; Wed, 3 Feb 2016 03:47:11 +0000 (UTC) (envelope-from wfdudley@gmail.com) Received: from mail-yw0-x236.google.com (mail-yw0-x236.google.com [IPv6:2607:f8b0:4002:c05::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BB9E9AD1 for ; Wed, 3 Feb 2016 03:47:10 +0000 (UTC) (envelope-from wfdudley@gmail.com) Received: by mail-yw0-x236.google.com with SMTP id q190so2651910ywd.3 for ; Tue, 02 Feb 2016 19:47:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=cTJ8G5WS+iMcCEIbweyTaZwyT0PkRpBTbLuNOEvFOEs=; b=vUBwQbbUE07bmjQ5qnagh1EpHiHGjk47P6kLn0OtojbT9wrH+RzxG8I81XToa/8djT HbnxEWYWjtP6QDIjDJLHyx22xNYalGYgOYc16osHJd5KAk4fpPW5BFTbs2AfhuCk70hl +ZMDwvuLNndoW4aYuX77lXQjZw6EZpNVxBwF/HaB+bJVB86y4b4+DqHAp7PHk7gMS4cB ZgAJC88ktRx6zx0dj3/WXD5RqKAnCLhv0bZ+OCHRo1Eu2HesUzjJKtS1A0mB8lDRJRWB dRRVb+5cKuGCHbN6RvxCE0xL1wRZIy6NKOHPY0dXkY29fFPCPiADTGJELH4GOUakpY6W 8tXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=cTJ8G5WS+iMcCEIbweyTaZwyT0PkRpBTbLuNOEvFOEs=; b=nG+Dk5V597HnG86IYKkoIznnPZtQs1nGJ4nLqTowD8O+wc1gIcZJnKoqjawYQIzraa ZUJ8q1/V+jHZziEy5fhknvQL70kyHOExeuJkhbs5HkSZ7dXl+uCwhbptpcJRuBV+e35N foZVD/0US5Y5zrFRU48eWJfnJ2491garpaCIP/7/P88ilVFK2PRZovP3zaFiKg73JKtA DOA2rTLNZCHEhVQSuV/n/ImWOsc99Upe1/Or+29n8LxTD3Tlbq5aZNAZ0Odw6UTVqWwg 1K58anolu3w5TFyLUZr6DYmGFLuTmyYG2MM9hexuF+pY5k0izk76su02+VPr34R7RSHa EQ0Q== X-Gm-Message-State: AG10YORgnnzzohZ1SbiXX1NcBQSQDkjGKGDKHUcuJjakIraVRbrffZWkqENs6LF5FriRWw== X-Received: by 10.129.38.10 with SMTP id m10mr14900658ywm.183.1454471230019; Tue, 02 Feb 2016 19:47:10 -0800 (PST) Received: from [192.168.27.26] (mail.casano.com. [98.109.205.15]) by smtp.googlemail.com with ESMTPSA id i6sm1912578ywe.11.2016.02.02.19.47.08 for (version=TLSv1/SSLv3 cipher=OTHER); Tue, 02 Feb 2016 19:47:08 -0800 (PST) Subject: Re: sh script help with numeric values To: freebsd-questions@freebsd.org References: <56B1765D.2060800@gmail.com> From: "William F. Dudley Jr." Message-ID: <56B1783B.7050109@gmail.com> Date: Tue, 2 Feb 2016 22:47:07 -0500 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <56B1765D.2060800@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Feb 2016 03:47:11 -0000 man printf Bill Dudley On 02/02/2016 10:39 PM, Ernie Luzar wrote: > Hello list > > I am having trouble getting leading zeros to show up. > The following is an example of what i mean. > > dirname="dir" > dup_count=000 > dup_times=5 > > while [ "${dup_count}" -ne "${dup_times}" ]; do > dup_count=$(( $dup_count + 001 )) > dname="${dirname}-${dup_count}" > echo "${dname}" > done > > Outputs this > dir-1 > dir-2 > dir-3 > dir-4 > dir-5 > > What I really want to see is this > dir-001 > dir-002 > dir-003 > dir-004 > dir-005 > dir-013 > dir-111 > ect > > How do I get the leading zeros to show? > > Thanks for your help > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org"