file2 contains multiple lines and multiple columns.
I want to do a script that compare the first column of file2 with the only column of file1 then took the lines that are the same and search for each line the whole line on file2 then write the result on a file that we can call RESULT.
Here is my script :
#!/bin/bash
more file2|awk '{print $1}'|while read line
do
grep $line file1
done|while read ligne
do
grep '^$ligne' file2
done
Sorry I will use Code Tags on my futur posts.
Example of file1: - unix
- Solaris
- HPUX
- AIX
Example of file2: - Threads java j2ee
- Solaris sparc OS
- AIX OS IBM
the result should be: - Solaris sparc OS
- AIX OS IBM
Thank you delugeag. When I use the "..." the script works.
#!/bin/bash
more file2|awk '{print $1}'|while read line
do
grep "$line" file1
done|while read ligne
do
grep "^$ligne" file2
done>RESULTAT
Can you tell me what the difference between "..." and '...' ?
How can I do to send the file RESULT to a specific mail ? for example resultat@resultat.com ?
Enclosing characters in single quotes preserves the literal value of
each character within the quotes. A single quote may not occur between
single quotes, even when preceded by a backslash.
Enclosing characters in double quotes preserves the literal value of
all characters within the quotes, with the exception of $, `, \, and,
when history expansion is enabled, !. The characters $ and ` retain
their special meaning within double quotes.