Sponsored Content
Top Forums Shell Programming and Scripting How to get difference of two array? Post 302884876 by Akshay Hegde on Wednesday 22nd of January 2014 09:24:24 AM
Old 01-22-2014
Quote:
Originally Posted by lokendrasb
Required Unix shell script which will identify the difference of String2 based on string1. I am facing this issue and unable to achieve the result.
Code:
String1= {1 3 lok kam}
String2= {3 kam 5}

Result should be like below:
Code:
Data is matching for: 3
Data is matching for: kam
Data is not matching for: 5

Thanks in advance.

Here is one way to do so

Code:
#!/bin/bash

String1="1 3 lok kam"
String2="3 kam 5"

for i in ${String2[@]}; do
    grep $i <<<$String1 >/dev/null
    [ $? -eq 0 ] && echo "Data is matching for:$i" || echo "Data is not matching for: $i"
done

Code:
$ bash test
Data is matching for:3
Data is matching for:kam
Data is not matching for: 5

 

10 More Discussions You Might Find Interesting

1. Programming

Creating an array to hold posix thread ids: Only dynamic array works

I am facing a strange error while creating posix threads: Given below are two snippets of code, the first one works whereas the second one gives a garbage value in the output. Snippet 1 This works: -------------- int *threadids; threadids = (int *) malloc (num_threads * sizeof(int)); ... (4 Replies)
Discussion started by: kmehta
4 Replies

2. Shell Programming and Scripting

Array Difference Sun Vs Linux

Hi All, I have a script in which an array is defined. when i run that on Linux box its fine but when i run on SunOS its points to the line where array is defined as below : syntax error at line 9 : `(' unexpected array defined as ID=( ~Hog ~Todd ~Mike ) Thanks in advance (0 Replies)
Discussion started by: ravi.sadani19
0 Replies

3. Shell Programming and Scripting

PHP: Search Multi-Dimensional(nested) array and export values of currenly worked on array.

Hi All, I'm writing a nagios check that will see if our ldap servers are in sync... I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable so...eg...let take the single array... (1 Reply)
Discussion started by: zeekblack
1 Replies

4. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below, I need to check if $datevar is present in $filename. If so, i need to replace $filename with the values in the array. I need the output inside an ARRAY How can this be done. Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies

5. Shell Programming and Scripting

check the difference between 2 array

Hello Thanks everyone for the help earlier, what I would like to learn now is how can I achieve the following : array1 = (1234567,7665456,998889,000909) array2 = (1234567,5581445,998889,000909) Result 5581445 doesn't exist on array1 Thank you (6 Replies)
Discussion started by: amlife
6 Replies

6. Programming

what is the main difference between difference between using nonatomic lseek and O_APPEND

I think both write at the end of the file ...... but is there a sharp difference between those 2 instruction ..... thank you this is my 3rd question today forgive me :D (1 Reply)
Discussion started by: fwrlfo
1 Replies

7. Shell Programming and Scripting

Bash 3.2 - Array / Regex - IF 3rd member in array ends in 5 digits then do somthing...

Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help. pesudo code if == ENDSINFIVEINTS ]]; then do... (4 Replies)
Discussion started by: briandanielz
4 Replies

8. Shell Programming and Scripting

Finding difference in between two array's of strings

Hi, Can anybody help me in finding the difference between two array elements with the help of code pls. purge=("Purge Concurrent Request and/or Manager Data" "Purge Signon Audit data" "Purge Obsolete Workflow Runtime Data" "Purge Logs and Closed System Alerts") purge_1=("Purge Obsolete... (3 Replies)
Discussion started by: Y.balakrishna
3 Replies

9. Shell Programming and Scripting

Bash arrays: rebin/interpolate smaller array to large array

hello, i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N. for case 1, I want to stretch N to fit M arrayHuge H = (... (2 Replies)
Discussion started by: f77hack
2 Replies

10. Shell Programming and Scripting

awk to calculate difference of split and sum the difference

In the awk I am trying to subtract the difference $3-$2 of each matching $4 before the first _ (underscore) and print that value in $13. I think the awk will do that, but added comments. What I am not sure off is how to add a line or lines that will add sum each matching $13 value and put it in... (2 Replies)
Discussion started by: cmccabe
2 Replies
DateTime::Locale::rw_RW(3)				User Contributed Perl Documentation				DateTime::Locale::rw_RW(3)

NAME
DateTime::Locale::rw_RW SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'rw_RW' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for Kinyarwanda Rwanda. DATA
This locale inherits from the DateTime::Locale::rw locale. It contains the following data. Days Wide (format) Kuwa mbere Kuwa kabiri Kuwa gatatu Kuwa kane Kuwa gatanu Kuwa gatandatu Ku cyumweru Abbreviated (format) mbe. kab. gtu. kan. gnu. gnd. cyu. Narrow (format) 2 3 4 5 6 7 1 Wide (stand-alone) Kuwa mbere Kuwa kabiri Kuwa gatatu Kuwa kane Kuwa gatanu Kuwa gatandatu Ku cyumweru Abbreviated (stand-alone) mbe. kab. gtu. kan. gnu. gnd. cyu. Narrow (stand-alone) 2 3 4 5 6 7 1 Months Wide (format) Mutarama Gashyantare Werurwe Mata Gicuransi Kamena Nyakanga Kanama Nzeli Ukwakira Ugushyingo Ukuboza Abbreviated (format) mut. gas. wer. mat. gic. kam. nya. kan. nze. ukw. ugu. uku. Narrow (format) 1 2 3 4 5 6 7 8 9 10 11 12 Wide (stand-alone) Mutarama Gashyantare Werurwe Mata Gicuransi Kamena Nyakanga Kanama Nzeli Ukwakira Ugushyingo Ukuboza Abbreviated (stand-alone) mut. gas. wer. mat. gic. kam. nya. kan. nze. ukw. ugu. uku. Narrow (stand-alone) 1 2 3 4 5 6 7 8 9 10 11 12 Quarters Wide (format) igihembwe cya mbere igihembwe cya kabiri igihembwe cya gatatu igihembwe cya kane Abbreviated (format) I1 I2 I3 I4 Narrow (format) 1 2 3 4 Wide (stand-alone) igihembwe cya mbere igihembwe cya kabiri igihembwe cya gatatu igihembwe cya kane Abbreviated (stand-alone) I1 I2 I3 I4 Narrow (stand-alone) 1 2 3 4 Eras Wide BCE CE Abbreviated BCE CE Narrow BCE CE Date Formats Full 2008-02-05T18:30:30 = Kuwa kabiri, 2008 Gashyantare 05 1995-12-22T09:05:02 = Kuwa gatanu, 1995 Ukuboza 22 -0010-09-15T04:44:23 = Kuwa gatandatu, -10 Nzeli 15 Long 2008-02-05T18:30:30 = 2008 Gashyantare 5 1995-12-22T09:05:02 = 1995 Ukuboza 22 -0010-09-15T04:44:23 = -10 Nzeli 15 Medium 2008-02-05T18:30:30 = 2008 gas. 5 1995-12-22T09:05:02 = 1995 uku. 22 -0010-09-15T04:44:23 = -10 nze. 15 Short 2008-02-05T18:30:30 = 08/02/05 1995-12-22T09:05:02 = 95/12/22 -0010-09-15T04:44:23 = -10/09/15 Default 2008-02-05T18:30:30 = 2008 gas. 5 1995-12-22T09:05:02 = 1995 uku. 22 -0010-09-15T04:44:23 = -10 nze. 15 Time Formats Full 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC Long 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC Medium 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Short 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 Default 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Datetime Formats Full 2008-02-05T18:30:30 = Kuwa kabiri, 2008 Gashyantare 05 18:30:30 UTC 1995-12-22T09:05:02 = Kuwa gatanu, 1995 Ukuboza 22 09:05:02 UTC -0010-09-15T04:44:23 = Kuwa gatandatu, -10 Nzeli 15 04:44:23 UTC Long 2008-02-05T18:30:30 = 2008 Gashyantare 5 18:30:30 UTC 1995-12-22T09:05:02 = 1995 Ukuboza 22 09:05:02 UTC -0010-09-15T04:44:23 = -10 Nzeli 15 04:44:23 UTC Medium 2008-02-05T18:30:30 = 2008 gas. 5 18:30:30 1995-12-22T09:05:02 = 1995 uku. 22 09:05:02 -0010-09-15T04:44:23 = -10 nze. 15 04:44:23 Short 2008-02-05T18:30:30 = 08/02/05 18:30 1995-12-22T09:05:02 = 95/12/22 09:05 -0010-09-15T04:44:23 = -10/09/15 04:44 Default 2008-02-05T18:30:30 = 2008 gas. 5 18:30:30 1995-12-22T09:05:02 = 1995 uku. 22 09:05:02 -0010-09-15T04:44:23 = -10 nze. 15 04:44:23 Available Formats d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 EEEd (d EEE) 2008-02-05T18:30:30 = 5 kab. 1995-12-22T09:05:02 = 22 gnu. -0010-09-15T04:44:23 = 15 gnd. Hm (H:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 9:05 -0010-09-15T04:44:23 = 4:44 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 PM 1995-12-22T09:05:02 = 9:05 AM -0010-09-15T04:44:23 = 4:44 AM Hms (H:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 9:05:02 -0010-09-15T04:44:23 = 4:44:23 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 PM 1995-12-22T09:05:02 = 9:05:02 AM -0010-09-15T04:44:23 = 4:44:23 AM M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 Md (M-d) 2008-02-05T18:30:30 = 2-5 1995-12-22T09:05:02 = 12-22 -0010-09-15T04:44:23 = 9-15 MEd (E, M-d) 2008-02-05T18:30:30 = kab., 2-5 1995-12-22T09:05:02 = gnu., 12-22 -0010-09-15T04:44:23 = gnd., 9-15 MMM (LLL) 2008-02-05T18:30:30 = gas. 1995-12-22T09:05:02 = uku. -0010-09-15T04:44:23 = nze. MMMd (MMM d) 2008-02-05T18:30:30 = gas. 5 1995-12-22T09:05:02 = uku. 22 -0010-09-15T04:44:23 = nze. 15 MMMEd (E MMM d) 2008-02-05T18:30:30 = kab. gas. 5 1995-12-22T09:05:02 = gnu. uku. 22 -0010-09-15T04:44:23 = gnd. nze. 15 MMMMd (MMMM d) 2008-02-05T18:30:30 = Gashyantare 5 1995-12-22T09:05:02 = Ukuboza 22 -0010-09-15T04:44:23 = Nzeli 15 MMMMEd (E MMMM d) 2008-02-05T18:30:30 = kab. Gashyantare 5 1995-12-22T09:05:02 = gnu. Ukuboza 22 -0010-09-15T04:44:23 = gnd. Nzeli 15 ms (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 y (y) 2008-02-05T18:30:30 = 2008 1995-12-22T09:05:02 = 1995 -0010-09-15T04:44:23 = -10 yM (y-M) 2008-02-05T18:30:30 = 2008-2 1995-12-22T09:05:02 = 1995-12 -0010-09-15T04:44:23 = -10-9 yMEd (EEE, y-M-d) 2008-02-05T18:30:30 = kab., 2008-2-5 1995-12-22T09:05:02 = gnu., 1995-12-22 -0010-09-15T04:44:23 = gnd., -10-9-15 yMMM (y MMM) 2008-02-05T18:30:30 = 2008 gas. 1995-12-22T09:05:02 = 1995 uku. -0010-09-15T04:44:23 = -10 nze. yMMMEd (EEE, y MMM d) 2008-02-05T18:30:30 = kab., 2008 gas. 5 1995-12-22T09:05:02 = gnu., 1995 uku. 22 -0010-09-15T04:44:23 = gnd., -10 nze. 15 yMMMM (y MMMM) 2008-02-05T18:30:30 = 2008 Gashyantare 1995-12-22T09:05:02 = 1995 Ukuboza -0010-09-15T04:44:23 = -10 Nzeli yQ (y Q) 2008-02-05T18:30:30 = 2008 1 1995-12-22T09:05:02 = 1995 4 -0010-09-15T04:44:23 = -10 3 yQQQ (y QQQ) 2008-02-05T18:30:30 = 2008 I1 1995-12-22T09:05:02 = 1995 I4 -0010-09-15T04:44:23 = -10 I3 yyQ (Q yy) 2008-02-05T18:30:30 = 1 08 1995-12-22T09:05:02 = 4 95 -0010-09-15T04:44:23 = 3 -10 Miscellaneous Prefers 24 hour time? Yes Local first day of the week Kuwa mbere SUPPORT
See DateTime::Locale. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT
Copyright (c) 2008 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module was generated from data provided by the CLDR project, see the LICENSE.cldr in this distribution for details on the CLDR data's license. perl v5.18.2 2017-10-06 DateTime::Locale::rw_RW(3)
All times are GMT -4. The time now is 11:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy