Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Simple question about charecter count Post 303034770 by kvosu on Sunday 5th of May 2019 04:14:41 PM
Old 05-05-2019
Simple question about charecter count

Hi, I have collection of letters in a column such as:
Code:
AA5678
AA9873434
..
..

I am trying to find the number of charecters in each.
Code:
"echo "AA5678"|wc -c

7----------------> why does it give 7 instead of 6?

Last edited by RavinderSingh13; 05-06-2019 at 03:38 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Ok simple question for simple knowledge...

Ok what is BSD exactly? I know its a type of open source but what is it exactly? (1 Reply)
Discussion started by: Corrail
1 Replies

2. Programming

Simple C question... Hopefully it's simple

Hello. I'm a complete newbie to C programming. I have a C program that wasn't written by me where I need to write some wrappers around it to automate and make it easier for a client to use. The problem is that the program accepts standard input to control the program... I'm hoping to find a simple... (6 Replies)
Discussion started by: Xeed
6 Replies

3. Shell Programming and Scripting

Comapring files charecter by charecter using AWK/Shell Script

Hi... I have a requrement to compare two files. for e.g. File 1 2007/08/19 09:48:10 DH-032 $APTA1: Device AATD8029 2007/08/19 09:48:10 DH-045 $APTA1: Device AATD8029 2007/08/19 09:48:10 DH-043 $APTA1: Device AATD8029 File 2 2007-08-19 09:48:10 DH-032... (1 Reply)
Discussion started by: evvander
1 Replies

4. UNIX for Dummies Questions & Answers

charecter or number

Hi Friends, How to check a variable value is either charecter or number? With Regards / Ganapati (1 Reply)
Discussion started by: ganapati
1 Replies

5. Shell Programming and Scripting

simple count script outputting mass errors

script outputting cant find anything wrong with the script either... : #!/bin/sh #count execution script time=0 while do if then time=`expr $time + 1` if then echo "The current tick is 100" fi fi (2 Replies)
Discussion started by: aspect_p
2 Replies

6. Shell Programming and Scripting

simple awk question to count columns

hi all here is a very simple question.. i want to count the number of columns using awk..my file looks like this: 1,2 1,2 1,2 1,2 1,2 1,2 1,2 1,2 i want to count number of columns and i so far i have: awk 'BEGIN {IFS=","} END {print NF}' data > data1 i am getting 1... (3 Replies)
Discussion started by: npatwardhan
3 Replies

7. Shell Programming and Scripting

Simple script to count files

Hello, I am new to shell scripting and I need your help. I have found similar scripts in the forum but I need further assistance. I am building a script to use hourly in cron to mailx me if the number of files in a path is less than e.g 100 I have started with the following: #!/bin/sh... (2 Replies)
Discussion started by: drbiloukos
2 Replies

8. Red Hat

Syslog.conf: looking for a simple answer on a simple question

Cheers! In /etc/syslog.conf, if an error type is not specified, is it logged anywhere (most preferable is it logged to /var/log/messages) or not? To be more precise I am interested in error and critical level messages. At default these errors are not specified in syslog.conf, and I need to... (6 Replies)
Discussion started by: dr1zzt3r
6 Replies

9. Shell Programming and Scripting

How to remove lines that exceed a certain charecter count?

I am trying to remove lines in a variable(nidlist) that exceed a certain charecter count(in this case 7). I am trying to incorparate the function that removes the lines that exceed 7 into this piece of code nidlist=$(print $nidlist |tr ';' '\n' | sort | uniq | tr '\n' ';') Thank... (4 Replies)
Discussion started by: ajetangay
4 Replies

10. Programming

Simple C program to count word lengths

So my program is not working and I keep changing it to figure out why. So I have two questions, can I do tracing similar to bash, and also what is wrong with this. The idea is simple, I want to count "word" lengths, with the loose definition of word not being a space, tab, or newline. Here is... (11 Replies)
Discussion started by: Riker1204
11 Replies
COUNT(3)								 1								  COUNT(3)

count - Count all elements in an array, or something in an object

SYNOPSIS
int count (mixed $array_or_countable, [int $mode = COUNT_NORMAL]) DESCRIPTION
Counts all elements in an array, or something in an object. For objects, if you have SPL installed, you can hook into count(3) by implementing interface Countable. The interface has exactly one method, Countable::count, which returns the return value for the count(3) function. Please see the Array section of the manual for a detailed explanation of how arrays are implemented and used in PHP. PARAMETERS
o $array_or_countable - An array or Countable object. o $mode - If the optional $mode parameter is set to COUNT_RECURSIVE (or 1), count(3) will recursively count the array. This is particu- larly useful for counting all the elements of a multidimensional array. Caution count(3) can detect recursion to avoid an infinite loop, but will emit an E_WARNING every time it does (in case the array contains itself more than once) and return a count higher than may be expected. RETURN VALUES
Returns the number of elements in $array_or_countable. If the parameter is not an array or not an object with implemented Countable inter- face, 1 will be returned. There is one exception, if $array_or_countable is NULL, 0 will be returned. Caution count(3) may return 0 for a variable that isn't set, but it may also return 0 for a variable that has been initialized with an empty array. Use isset(3) to test if a variable is set. EXAMPLES
Example #1 count(3) example <?php $a[0] = 1; $a[1] = 3; $a[2] = 5; $result = count($a); // $result == 3 $b[0] = 7; $b[5] = 9; $b[10] = 11; $result = count($b); // $result == 3 $result = count(null); // $result == 0 $result = count(false); // $result == 1 ?> Example #2 Recursive count(3) example <?php $food = array('fruits' => array('orange', 'banana', 'apple'), 'veggie' => array('carrot', 'collard', 'pea')); // recursive count echo count($food, COUNT_RECURSIVE); // output 8 // normal count echo count($food); // output 2 ?> SEE ALSO
is_array(3), isset(3), strlen(3). PHP Documentation Group COUNT(3)
All times are GMT -4. The time now is 04:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy