From owner-freebsd-questions@freebsd.org Sat Sep 9 18:22:24 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 0CDF2E00A1C for ; Sat, 9 Sep 2017 18:22:24 +0000 (UTC) (envelope-from mfv@bway.net) Received: from smtp1.bway.net (smtp1.v6.bway.net [IPv6:2607:d300:1::27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E013B729C6 for ; Sat, 9 Sep 2017 18:22:23 +0000 (UTC) (envelope-from mfv@bway.net) Received: from gecko4 (host-216-220-115-161.dsl.bway.net [216.220.115.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: m1316v@bway.net) by smtp1.bway.net (Postfix) with ESMTPSA id 0E37F958B1 for ; Sat, 9 Sep 2017 14:22:10 -0400 (EDT) Date: Sat, 9 Sep 2017 14:22:10 -0400 From: mfv To: freebsd-questions@freebsd.org Subject: Re: Why does wc increase character count by 1 ? Message-ID: <20170909142210.23ed38e2@gecko4> In-Reply-To: References: Reply-To: mfv@bway.net MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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:22:24 -0000 > On Sat, 2017-09-09 at 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 >_______________________________________________ >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" Hello, It appears to be counting the new line. Use "echo -n" to NOT count the new line. echo "abc 123" | wc produces: 1 2 8 echo -n "abc 123" | wc produces: 0 2 7 Cheers ... Marek