Sponsored Content
Full Discussion: find from the list
Top Forums UNIX for Dummies Questions & Answers find from the list Post 302598519 by pavan_test on Tuesday 14th of February 2012 07:01:09 PM
Old 02-14-2012
find from the list

Hi All,

I have list such as

list1:
Code:
Honda, toyota, GMC

list2:
Code:
kia, chrysler, toyota

Code:
when list1 match with list2 then
   echo "run this script"
else
   echo "run the script2"

can somone please let me how can I accomplish this in korn shell. The values from the list1 are passed to the script as a runtime parameters.

I tried somethis like this,
Code:
if [ $list1 != $list2 ]; then 
   echo "run this script"
else
   echo "run the script2"

when I ran the script, ksh myscript toyota
the script is comparing toyota with kia from list2 and displaying echo "run this script"


however I have toyota in the list2.

Thanks
pavan

---------- Post updated at 08:01 PM ---------- Previous update was at 07:05 PM ----------

The data from list2 will be coming from database. Not always sorted. I can sort this data but the data from the list1 will never be sorted.

Moderator's Comments:
Mod Comment Use code tags, see PM.

Last edited by zaxxon; 02-14-2012 at 08:27 PM.. Reason: code tags, see PM
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

command find returned bash: /usr/bin/find: Argument list too long

Hello, I create a file touch 1201093003 fichcomp and inside a repertory (which hava a lot of files) I want to list all files created before this file : find *.* \! -maxdepth 1 - newer fichcomp but this command returned bash: /usr/bin/find: Argument list too long but i make a filter all... (1 Reply)
Discussion started by: yacsil
1 Replies

2. Shell Programming and Scripting

How to find the list of files

How to find the list of files of particular type present in Directory and sub-directory. (2 Replies)
Discussion started by: senthilk615
2 Replies

3. Shell Programming and Scripting

find list of files from a list and copy to a directory

I will be very grateful if someone can help me with bash shell script that does the following: I have a list of filenames: A01_155716 A05_155780 A07_155812 A09_155844 A11_155876 that are kept in different sub directories within my current directory. I want to find these files and copy... (3 Replies)
Discussion started by: manishabh
3 Replies

4. Shell Programming and Scripting

Find and list script

Hello All, ksh script. Please consider the following case . $ ls -l -rw-r----- 1 100 400 405143552 Mar 21 2010 bz_1_0000063547_561428818.arc -rw-r----- 1 100 400 404148224 Feb 19 09:55 bz_1_0000079359_561428818.arc -rw-r----- 1 100 400 405625856 Feb 19 14:30... (2 Replies)
Discussion started by: yoavbe
2 Replies

5. UNIX for Advanced & Expert Users

Recursion list for rm -R in find

In the following command: find / -ctime +3 -exec rm -R {}\; how is the recursion list built for the actual rm ? F'rinstance; I had a case where a user typed this as root using '/' instead of '.' so everything in the root level was going to be traversed. They hit <ctrl>C before too much was... (5 Replies)
Discussion started by: port43
5 Replies

6. Shell Programming and Scripting

How to find the X highest values in a list depending on the values of another list with bash/awk?

Hi everyone, This is an exemple of inpout.txt file (a "," delimited text file which can be open as csv file): ID, Code, Value, Store SP|01, AABBCDE, 15, 3 SP|01, AABBCDE, 14, 2 SP|01, AABBCDF, 13, 2 SP|01, AABBCDE, 16, 3 SP|02, AABBCED, 15, 2 SP|01, AABBCDF, 12, 3 SP|01, AABBCDD,... (1 Reply)
Discussion started by: jeremy589
1 Replies

7. Shell Programming and Scripting

Find the nth value in a list

Hello, I have some code that searches file names, sorts them on a field in the name, and returns the top value. # list the contents, strip off the path, and sort on field 3 as a number, returns top value TOP_OUTCOME=$(ls './'$SET_F'/'$FOLD'/'$FOLD'_anneal/'$C_PARAMS'/'$A_SET'/'*'out.txt' |... (4 Replies)
Discussion started by: LMHmedchem
4 Replies

8. Shell Programming and Scripting

Find command to find a word from list of files

I need to find a word '% Retail by State' in the folder /usr/sas/reports/RetailSalesTaxallocation. When I tried like below, -bash-4.1$ cd /usr/sas/reports/RetailSalesTaxallocation -bash-4.1$ find ./ -name % Retail by State find: paths must precede expression: Retail Usage: find ... (10 Replies)
Discussion started by: Ram Kumar_BE
10 Replies
libtar_list_new(3)						  C Library Calls						libtar_list_new(3)

NAME
libtar_list_new, libtar_list_free, libtar_list_next, libtar_list_prev, libtar_list_add, libtar_list_del, libtar_list_search, lib- tar_list_dup, libtar_list_merge, libtar_list_add_str - linked list routines SYNOPSIS
#include <libtar.h> libtar_list_t *libtar_list_new(int flags, int (*cmpfunc)()); void libtar_list_free(libtar_list_t *l, void (*freefunc)()); int libtar_list_add_str(libtar_list_t *l, char *str, char *delim); int libtar_list_add(libtar_list_t *l, void *data); void libtar_list_del(libtar_list_t *l, libtar_node_t **n); int libtar_list_search(libtar_list_t *l, libtar_node_t **n, void *data, int (*matchfunc)()); int libtar_list_next(libtar_list_t *l, libtar_node_t **n); int libtar_list_prev(libtar_list_t *l, libtar_node_t **n); libtar_list_t *libtar_list_dup(libtar_list_t *l); libtar_list_t *libtar_list_merge(int (*cmpfunc)(), int flags, libtar_list_t *list1, libtar_list_t *list2); DESCRIPTION
The libtar_list_new() function creates a new list. The flags argument must be one of the following values: LIST_USERFUNC The cmpfunc argument points to a user-supplied function which determines the ordering of the list. LIST_STACK Use the list as a stack. New elements are added to the front of the list. LIST_QUEUE Use the list as a queue. New elements are added to the end of the list. The libtar_list_free() function deallocates all memory associated with the list l. If freefunc is not NULL, it is called to free memory associated with each node in the list. The libtar_list_add() function adds the element pointed to by data to the list l. The position of the new element will be determined by the flags passed to libtar_list_new() when the list was created. The libtar_list_add_str() function tokenizes the string str using the delimiter characters in the string delim. The resulting tokens are added to list l using libtar_list_add(). The libtar_list_search() function searches for an element which matches data using the matching function matchfunc. If matchfunc is NULL, a default matching function designed for ASCII strings is used. Searching begins from the node pointed to by n. The libtar_list_del() function removes the entry pointed to by n from the list pointed to by l. The libtar_list_dup() function creates a copy of the list l using dynamically allocated memory. The libtar_list_merge() function creates a new list with flags and cmpfunc, in the same way as libtar_list_new(). It then adds all ele- ments from list1 and list2 using libtar_list_add(). RETURN VALUE
The libtar_list_new(), libtar_list_dup(), and libtar_list_merge() functions return a pointer to the new list structure, or NULL on error. The libtar_list_next(), libtar_list_prev(), and libtar_list_search() functions return 1 when valid data is returned, or 0 otherwise. The libtar_list_add() and libtar_list_add_str() functions return 0 on success, or -1 on error. SEE ALSO
libtar_hash_new(3) University of Illinois Jan 2000 libtar_list_new(3)
All times are GMT -4. The time now is 07:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy