Sponsored Content
Top Forums Shell Programming and Scripting Compare string length to a number Post 302979963 by rajneesh4U on Monday 22nd of August 2016 11:50:23 AM
Old 08-22-2016
Hi,
Still code is showing same error. I have changed below code as per your suggestion, but still not working.
Code:
#bin !/bin/bash
clear
echo -n "Enter name "
read name
IFS=_
ary=($name)
for key in "${!ary[@]}"; do echo "$key${ary[$key]}"; done
##First name should be equal to 8 digits
var=${ary[0]}
l1=${#var}

echo "$l1"

if [ ["$l1" == 8]]
then 
echo "Length Matching"
else
echo "Not Matching"
if

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed problem - replacement string should be same length as matching string.

Hi guys, I hope you can help me with my problem. I have a text file that contains lines like this: 78 ANGELO -809.05 79 ANGELO2 -5,000.06 I need to find all occurences of amounts that are negative and replace them with x's 78 ANGELO xxxxxxx 79... (4 Replies)
Discussion started by: amangeles
4 Replies

2. Shell Programming and Scripting

read string, check string length and cut

Hello All, Plz help me with: I have a csv file with data separated by ',' and optionally enclosed by "". I want to check each of these values to see if they exceed the specified string length, and if they do I want to cut just that value to the max length allowed and keep the csv format as it... (9 Replies)
Discussion started by: ozzy80
9 Replies

3. Shell Programming and Scripting

how can i compare te length of the string

how can i campare te length of the string $var = unix if ( $var -eq 4 ) then.. is it right (6 Replies)
Discussion started by: mail2sant
6 Replies

4. Shell Programming and Scripting

How to Compare two files depend on line length Chars

I need to compare two files with exactly same length as example: - File1 contain 500 records with length of 640 chars of each line. File2 contain 1500 records with length of 640 chars of each line. I need get an output to be written in File3 which will contain 1000 records difference. but... (4 Replies)
Discussion started by: elj3dah
4 Replies

5. UNIX for Dummies Questions & Answers

Read a string with leading spaces and find the length of the string

HI In my script, i am reading the input from the user and want to find the length of the string. The input may contain leading spaces. Right now, when leading spaces are there, they are not counted. Kindly help me My script is like below. I am using the ksh. #!/usr/bin/ksh echo... (2 Replies)
Discussion started by: dayamatrix
2 Replies

6. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

7. UNIX for Dummies Questions & Answers

compare 2 very large lists of different length

I have two very large datasets (>100MB) in a simple vertical list format. They are of different size and with different order and formatting (e.g. whitespace and some other minor cruft that would thwart easy regex). Let's call them set1 and set2. I want to check set2 to see if it contains... (2 Replies)
Discussion started by: uiop44
2 Replies

8. Shell Programming and Scripting

[awk]compare a number in a string with a list

Hi, I have a program written in awk and I want to extend it to do another task. My program is a list of CVS log reports of a repository. For each file, I have some fields. One of the fields is the comment field. I want to know how I can check if a comment (which is a free text field)... (8 Replies)
Discussion started by: sandeepk1611
8 Replies

9. Shell Programming and Scripting

Pass column number as variable to awk and compare with a string.

Hi All, I have a file test.txt. Content of test.txt : 1 vinay se 2 kumar sse 4 kishore tl I am extracting the content of file with below command. awk '$2 ~ "vinay" {print $0}' test.txt Now instead of hardcoding $2 is there any way pass $2 as variable and compare with a... (7 Replies)
Discussion started by: Girish19
7 Replies

10. UNIX for Beginners Questions & Answers

Concatenate a string and number and compare that with another string in awk script

I have below code inside my awk script if ( $0 ~ /SVC IN:/ ) { svc_in=substr( $0,23 , 3); if (msg_start == 1 && msg_end == 0) { msg_arr=$0; } } else if ( $0 ~ /^SVC OUT:/ ) { svc_out=substr( $0, 9, 3); if (msg_start == 1 && msg_end == 0) ... (6 Replies)
Discussion started by: bhagya123
6 Replies
MB_DETECT_ORDER(3)							 1							MB_DETECT_ORDER(3)

mb_detect_order - Set/Get character encoding detection order

SYNOPSIS
mixed mb_detect_order ([mixed $encoding_list = mb_detect_order()]) DESCRIPTION
Sets the automatic character encoding detection order to $encoding_list. PARAMETERS
o $encoding_list -$encoding_list is an array or comma separated list of character encoding. See supported encodings. If $encoding_list is omitted, it returns the current character encoding detection order as array. This setting affects mb_detect_encoding(3) and mb_send_mail(3). mbstring currently implements the following encoding detection filters. If there is an invalid byte sequence for the following encodings, encoding detection will fail. UTF-8, UTF-7, ASCII, EUC-JP, SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP For ISO-8859-*, mbstring always detects as ISO-8859-*. For UTF-16, UTF-32, UCS2 and UCS4, encoding detection will fail always. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 mb_detect_order(3) examples <?php /* Set detection order by enumerated list */ mb_detect_order("eucjp-win,sjis-win,UTF-8"); /* Set detection order by array */ $ary[] = "ASCII"; $ary[] = "JIS"; $ary[] = "EUC-JP"; mb_detect_order($ary); /* Display current detection order */ echo implode(", ", mb_detect_order()); ?> Example #2 Example showing useless detect orders ; Always detect as ISO-8859-1 detect_order = ISO-8859-1, UTF-8 ; Always detect as UTF-8, since ASCII/UTF-7 values are ; valid for UTF-8 detect_order = UTF-8, ASCII, UTF-7 SEE ALSO
mb_internal_encoding(3), mb_http_input(3), mb_http_output(3), mb_send_mail(3). PHP Documentation Group MB_DETECT_ORDER(3)
All times are GMT -4. The time now is 09:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy