From owner-freebsd-questions@freebsd.org Sat Sep 9 18:15:01 2017 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 B0A81E002BC for ; Sat, 9 Sep 2017 18:15:01 +0000 (UTC) (envelope-from matt.xtaz@gmail.com) Received: from mail-wr0-x22f.google.com (mail-wr0-x22f.google.com [IPv6:2a00:1450:400c:c0c::22f]) (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 40BD3724A2 for ; Sat, 9 Sep 2017 18:15:01 +0000 (UTC) (envelope-from matt.xtaz@gmail.com) Received: by mail-wr0-x22f.google.com with SMTP id 108so8666854wra.5 for ; Sat, 09 Sep 2017 11:15:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Yp/BGqbNfewKAss+SRzvnzXbFo0Nu2viyPg4tvuJY1I=; b=NvxVj7ZlODWCpOT9ERxEfTJ+Mk790fsk0pYrOvh1tdpiMTegj4A5uTWu/OamUu0P37 g7nMIjkLWBbgRwixvjicNgMU7sZRMEf/WumLfsBNznTiuPgJ0G2oSr8RP1X56AsmwYE+ znPM0fTlQZHtmHuNG8BV/osed+c9oghKeRmXMLr1dLJOcYoMUkoK/CAGbU/JC1xYCm1t BAHsAZS6YvYc4K1riamuI0R0ElqsnXiyB9PqGX79oQVWthTAJVu/HJzDJvbBIxZcyGsR gv2wFJhp+UL/TOC2bMCDCmzr/y2JC/aST9Y/oFVE5lThq+TZpBCZ5dEzyjAUI+BC51c3 haTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=Yp/BGqbNfewKAss+SRzvnzXbFo0Nu2viyPg4tvuJY1I=; b=WfgrpRp/ABVhQy5TgfU1nazBaD2CxxRt5JIo7CPL1hZd0a0LQ+vMqv8jlSquMYC3pF LUdbwHy9gM9n3Dbu1WuNrfajuHCFfzNhEo0/9pguPqFtOhrAPkGx5lp2eEPzpSfw7EiT UnFhkp5yj+cVQfr/OJEBSayrY8gAWByUet58YR42qmMG+ERG26c5oMFpk/nAN0wbNvAY FVv4Jy/XQSpdPa2RHsbAlLbWRKEajQEY60s3fS66eNDtqFafr83DxZzb2QTXvhjCYKDl HEKlYhMvAaM6E9cbHckcRPvrddx7zbZiktocc9ZCXE6v4++ZtTSi6yoiXB6jZyI416Hg qbHw== X-Gm-Message-State: AHPjjUi92n1vdZPhjGKnDStPBxyRJaDe0GxFD++JwtmWmUtn3LWh9rYS ndL6YJmTXZw5Hw== X-Google-Smtp-Source: ADKCNb6+WaH0MrT8a0WMprMGlgUUgHoJSNn46orUV8MzG2whPe/51jAl1LpxldU5GKIwWcBHxKPO3A== X-Received: by 10.223.163.83 with SMTP id d19mr4630426wrb.84.1504980898587; Sat, 09 Sep 2017 11:14:58 -0700 (PDT) Received: from gmail.com (tao.xtaz.uk. [2001:8b0:fe33::10]) by smtp.gmail.com with ESMTPSA id f43sm5654353wra.79.2017.09.09.11.14.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Sep 2017 11:14:58 -0700 (PDT) Date: Sat, 9 Sep 2017 19:14:56 +0100 From: Matt Smith To: Manish Jain Cc: "freebsd-questions@freebsd.org" Subject: Re: Why does wc increase character count by 1 ? Message-ID: <20170909181455.GB82102@gmail.com> Mail-Followup-To: Matt Smith , Manish Jain , "freebsd-questions@freebsd.org" References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.3 (2017-05-23) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Sep 2017 18:15:01 -0000 On Sep 09 18:10, Manish Jain wrote: >Hi, > >echo "abc 123" | wc -c > >I would expect wc to output 7, but actually I get 8. > >Indeed, I see similar behaviour with 'echo | wc -c' >This should produce 0, but I get 1 > >What might be the problem ? Thanks for any tips. >Manish Jain It's counting the \n linefeed. Try these: echo "abc 123" | od -c echo -n "abc 123" | od -c echo -n "abc 123" | wc -c -- Matt