-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3
More file actions
29 lines (26 loc) · 742 Bytes
/
3
File metadata and controls
29 lines (26 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
FILE1='somefile'
FILE2='someotherfile'
# File 1, column 1
f1c1=($(cut -f1 -s $FILE1))
# File 1, column 2
#f1c2=($(cut -f2 -s $FILE1))
# File 2, column 1
f2c1=($(cut -f1 -s $FILE2))
# File 2, column 2
#f2c2=($(cut -f2 -s $FILE2))
# Looping through all items in file 1 column 1
for x in "${f1c1[@]}"
do
# For each item in f1c1, check all items in f2c1 for a match
for y in "${f2c1[@]}"
do
if [[ $x == $y ]]
then
# The items matched!
echo $x
# Breaking out of the loop (no need to check for more than one
# match, right?)
break
fi
done
done