samedi 28 juillet 2018

if - else - Bash

Input file "temp.txt" has multiple lines. Script will parse temp.txt and search for these strings on different files. If result is "True", don't check other files and continue with next object. Is there any way to accomplish this?

temp.txt

abc
abd
abe
abf
abg

xyz

f1
f2
f3
f4
f5

Script:

function command() {
    if [ "$a -ne 0 ]; then
            echo "$i" 'True';
            else
            echo "$i" 'false';
    fi
}     


for x in (xyz)
    do
    cd $x;
    for i in `cat "temp.txt"`; do 
    command $i
    done

Aucun commentaire:

Enregistrer un commentaire