Linux array, remove duplicate values

2011-09-24  来源:本站原创  分类:OS  人气:54 

#! / Bin / sh

array = ("java" "linux" "c" "linux" "c + +" "java")
len = $ {# array [@]}
for ((i = 0; i <$ len; i + +))
do
for ((j = $ len-1; j> i; j -))
do
if [[$ {array [i]} = $ {array [j]}]]; then
unset array [i]
fi
done
done

for arr in $ {array [@]}
do
echo $ arr
done

[Root @ bogon shell] # ./array1.sh

c

linux

c + +

java

相关文章
  • Linux array, remove duplicate values 2011-09-24

    #! / Bin / sh array = ("java" "linux" "c" "linux" "c + +" "java") len = $ {# array [@]} for ((i = 0; i <$ len; i + +)) do for ((j = $ len-1; j> i; j -)) do if [[$ {array [i]} = $ {array [j]

  • Check whether the array contains duplicate values which 2010-06-11

    Check whether an array contains duplicate values which function TForm.BinarySearch(a:array of Integer):Integer; var i,j,temp:Integer; begin Result:=-1; if Length(a)>0 then begin for i :=0 to Length(a)-1 do begin temp:=a[i]; for j :=i+1 to Length(a)-1

  • List list to remove duplicate values (3 solutions) 2010-12-03

    public static void main(String[] args) { String[] ar = { "dd", "c", "dd", "ff", "b", "e", "e" }; ArrayList list = new ArrayList(); for (int i = 0; i < ar.length; i++) { list.add(ar[i

  • asp.net remove duplicate string array to remove duplicate values 2010-04-29

    1.string str = "1,22,333,4,5,1,22,333,6,7 ,";// to split string 2.ArrayList al = new ArrayList (); 3.string [] arr = str.Split (',');// character array after the split 4. 5.for (int i = 0; i <arr.Length; i + +) 6. ( 7. If (al.Contains (arr [i

  • javascript array to remove duplicate values 2010-12-22

    var array = [1,1,2,2,3,3]; var newArry = []; for (var x in array) { newArry [array [x]] = ""; } for (var y in newArry) { alert (y); } This algorithm is an absolute classic, the use of an array subscript to remove, it is high var s = ["a&quo

  • Remove duplicate values distinct mysql 2010-07-30

    When using mysql, and sometimes need to check out a field does not duplicate records, although there are distinct mysql provides the keyword to filter out unwanted duplicate records to retain only one, but often do not use it to return to the Number

  • MySQL query results to remove duplicate values 2011-05-11

    Transfer from: phpv Of: Saul content: the process of learning distinct, it is worth drawing ah ^ ^ -------------------------------------------------- ------------------------------ When using mysql, and sometimes do not need to check out a field dupl

  • sql remove duplicate values 2011-01-06

    CREATE TABLE [dbo]. [HQEW] ( [ID] [bigint] NOT NULL, [Supplier] [varchar] (200) NULL, [Manufacturers] [varchar] (50) NULL, [Model] [varchar] (50) NULL, [Inventory] [varchar] (50) NULL, [Address] [varchar] (50) NULL, [Environment] [varchar] (50) NULL,

  • php processing two-dimensional array (remove duplicates, sort, transform, etc.) 2010-07-08

    1. PHP function of two-dimensional array to duplicate items PHP array to remove duplicate items have a built-in function array_unique (), but php's array_unique function only applies to one-dimensional arrays, multidimensional arrays is not applicabl

  • php processing two-dimensional array (remove duplicates, sort, transform, go blank, etc.) 2010-07-08

    1. PHP function of two-dimensional array to duplicate items PHP array to remove duplicate items have a built-in function array_unique (), but php's array_unique function only applies to one-dimensional arrays, multidimensional arrays is not applicabl

  • With array_flip () Remove duplicate elements in array 2010-08-06

    In PHP, used to remove duplicate elements in an array of functions available, it is array_unique (), but it is not the most efficient way of using array_flip () function than array_uniqure () five times higher in speed about. As follows: $ Arr = arra

  • JS to remove duplicate items 2009-04-18

    <html> <head> <title> to remove duplicate characters! </ title> </ head> <body> <form> <table width="50%" align="center" border="0"> <tr> <td align="center"&g

  • Hibernate using Criteria queries to remove duplicate data using the Distinct 2010-05-11

    [Hibernate] Hibernate using Criteria queries to remove duplicate data using the Distinct Polls | Delete / / Fragment of code Criteria criteria = session.createCriteria (User.class); criteria.add (Restrictions.like ("name", name, MatchMode.ANYWHE

  • Set list by removing duplicate values in the 2010-11-17

    Today, when encountered in the development of removing duplicate values in the list, remove the duplicate values is divided into two situations: 1. On the original list order does not require public static void removeDuplicate(ArrayList arlList) { Ha

  • ORACLE how to remove duplicate data in the table 2011-05-27

    How to delete a table in ORACLE duplicate data in this situation we may, the original design is not a comprehensive list, resulting in duplication of data table inside the data, then, how to duplicate data delete? Duplicate data may have two such cas

  • Remove duplicate data in the method 2011-02-27

    - Remove duplicate records in the table. create table user_info ( username varchar2 (20), password varchar2 (20) ) insert into user_info values ​​('JACK', '123 ', SQ_USER.NEXTVAL); insert into user_info values ​​('JACK', '123 ', SQ_USER.NEXTV); inser

  • Remove duplicate string Oracle 2011-06-02

    Weight create or replace function remove_rame_string(oldStr varchar2, sign varchar2) return varchar2 is /**************************************************** ** Oracle Remove duplicate string ** The function name :RemoveSameStr ** Parameters :[ The n

  • Linux add / remove users and user groups 2010-04-28

    Linux add / remove users and user groups 1, build the user: adduser phpq / / New phpq Users passwd phpq / / user password to phpq 2, the construction of the Working Group groupadd test / / New test of the Working Group 3, new users and increase the w

  • Microsoft SQL Server, remove duplicate data in several ways 2010-07-21

    Method 1 declare @ max integer, @ id integer declare cur_rows cursor local for select main field, count (*) from Table group by name of the main field having count (*)> 1 open cur_rows fetch cur_rows into @ id, @ max while @ @ fetch_status = 0 begin

  • Remove duplicate records and duplicate records common method of query 2010-08-10

    Remove duplicate records and duplicate records common method of query Oracle tests and records through a table as follows: SQL> select * from testa; A AA AAA ---------- ---------- ---------- a1 aa1 aaa1 a1 aa1 aaa2 a1 aa1 aaa3 a2 aa3 aaa3 a2 aa3 aaa3