Sponsored Content
Full Discussion: check number of character
Top Forums Shell Programming and Scripting check number of character Post 302358964 by vino on Monday 5th of October 2009 10:00:00 AM
Old 10-05-2009
Quote:
Originally Posted by francis_tom
hi,

I would like to calculate number of character for a number,

for exemple : 1200 --> there are 4 characters , 120001 -> 5 characters
Code:
a=1200
echo ${#a}

And number of characters in 120001 is 6 and not 5.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Number or Character

How to find that a given variable is a number or character? e.g. echo "Enter the number" read var If "$var" is a number then display "Number has been entered" else display "Character has been entered". Thanking you in advance (3 Replies)
Discussion started by: j1yant
3 Replies

2. UNIX for Dummies Questions & Answers

check for the first character to be blank

I'm having a problem when the first line or first character of a file is blank. I need to get rid of both of them when they occur but don't want to delete the line. Does anyone have any suggestions? (7 Replies)
Discussion started by: anthreedhr
7 Replies

3. UNIX for Dummies Questions & Answers

how to check first character in var's value.

Currently my script works like this: DATE_dd=5 # Assume this is user input. (User can enter 1, 2, 3, .. 10, 11, 12) if ; then DATE_D=" ${DATE_dd}" file_name="${DATE_yyyy}${DATE_mm}0${DATE_dd}.csv" else DATE_D=${DATE_dd} ... (7 Replies)
Discussion started by: yongho
7 Replies

4. Shell Programming and Scripting

how to check string of character

how can i check whether variable contains only character from a-z or A-Z....if my variable contains any alpha numeric, numeric or any character with some special one i.e. *%&@! etcetera etcetera....then it should show me please enter only characters...... Let my variable var1="abc77}|" then... (9 Replies)
Discussion started by: manas_ranjan
9 Replies

5. AIX

check for a particular character inside a file and substitute with a given character?

i am a newbie to shell script,so i want a kshell script in which i need to check for a particular character inside a file through conditional looping(like if ,case,while)and if that character exists ,then substitute a given character to that character. consider a file test.txt,inside the file... (1 Reply)
Discussion started by: karthikprasathk
1 Replies

6. Shell Programming and Scripting

To check if the first character is a alphabet or number

Hi, I need to find whether the first character in a line is a alphabet or a number. If its a number i should sort it numerically. If its a alphabet i should sort it based on the ASCII value.And if it is something other than alphabet or number then sort it based on ASCII value. The code i used... (2 Replies)
Discussion started by: ragavhere
2 Replies

7. Shell Programming and Scripting

check whether it is a non-numeric character

Below is the abstract of the script which is working fine. if ] then error_process "Invalid month format." return 1 fi I am doing validation for month and it errors if the value is > 12 or < 0. In addition, I want to add another condition to error if it... (2 Replies)
Discussion started by: sony_dada
2 Replies

8. Shell Programming and Scripting

How to check for special character in a value

Hi, I have a variable and to it always alphanumeric value will be assigned. If the value has any special characters in it then in the if statement it should exit like below if (value has any speacial character) then exit else .... fi can any one suggest how to acheive this? (4 Replies)
Discussion started by: lavnayas
4 Replies

9. Shell Programming and Scripting

Count number of occurences of a character in a field defined by the character in another field

Hello, I have a text file with n lines in the following format (9 column fields): Example: contig00012 149606 G C 49 68 60 18 c$cccccacccccccccc^c I need to count the number of lower-case and upper-case occurences in column 9, respectively, of the... (3 Replies)
Discussion started by: s052866
3 Replies

10. Shell Programming and Scripting

check number or character of a file

Hi, Please see the below information. 1. Read files one by one and run the script. 2. Check if the filename is CHARTER OR NUMBER 3. Run the case statement. I have files in the folder. i will get 300 files in a single day. Abc_111111111111.csv 101010_kkk_bbbb.csv... (6 Replies)
Discussion started by: onesuri
6 Replies
GLOB(7) 					       BSD Miscellaneous Information Manual						   GLOB(7)

NAME
glob -- shell-style pattern matching DESCRIPTION
Globbing characters (wildcards) are special characters used to perform pattern matching of pathnames and command arguments in the csh(1), ksh(1), and sh(1) shells as well as the C library functions fnmatch(3) and glob(3). A glob pattern is a word containing one or more unquoted '?' or '*' characters, or ``[..]'' sequences. Globs should not be confused with the more powerful regular expressions used by programs such as grep(1). While there is some overlap in the special characters used in regular expressions and globs, their meaning is different. The pattern elements have the following meaning: ? Matches any single character. * Matches any sequence of zero or more characters. [..] Matches any of the characters inside the brackets. Ranges of characters can be specified by separating two characters by a '-' (e.g. ``[a0-9]'' matches the letter 'a' or any digit). In order to represent itself, a '-' must either be quoted or the first or last character in the character list. Similarly, a ']' must be quoted or the first character in the list if it is to represent itself instead of the end of the list. Also, a '!' appearing at the start of the list has special meaning (see below), so to represent itself it must be quoted or appear later in the list. Within a bracket expression, the name of a character class enclosed in '[:' and ':]' stands for the list of all characters belonging to that class. Supported character classes: alnum cntrl lower space alpha digit print upper blank graph punct xdigit These match characters using the macros specified in ctype(3). A character class may not be used as an endpoint of a range. [!..] Like [..], except it matches any character not inside the brackets. Matches the character following it verbatim. This is useful to quote the special characters '?', '*', '[', and '' such that they lose their special meaning. For example, the pattern ``\*[x]?'' matches the string ``*[x]?''. Note that when matching a pathname, the path separator '/', is not matched by a '?', or '*', character or by a ``[..]'' sequence. Thus, /usr/*/*/X11 would match /usr/X11R6/lib/X11 and /usr/X11R6/include/X11 while /usr/*/X11 would not match either. Likewise, /usr/*/bin would match /usr/local/bin but not /usr/bin. SEE ALSO
fnmatch(3), glob(3), re_format(7) HISTORY
In early versions of UNIX, the shell did not do pattern expansion itself. A dedicated program, /etc/glob, was used to perform the expansion and pass the results to a command. In Version 7 AT&T UNIX, with the introduction of the Bourne shell, this functionality was incorporated into the shell itself. BSD
November 30, 2010 BSD
All times are GMT -4. The time now is 11:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy