find from the list


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers find from the list
# 1  
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
# 2  
Old 02-14-2012
do you want to compare element by element in the lists, or just find if an element in list 1 is somewhere in list 2 (or an element in list 2 is in list 1 somewhere)
# 3  
Old 02-14-2012
find from the list

I don't have to compare element by element in the lists.

Just find

if an element in list1 is somewhere in list 2 then
echo "run the script2"
else
echo "run the script1"

Thanks
Pavan
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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
Login or Register to Ask a Question