Quantcast
Viewing all articles
Browse latest Browse all 5

Answer by user88036 for Link variables between two text files

You can achieve what you want using case control structure as follows:

#!/bin/bashlog1_length=$(wc -l <log1.txt)log2_length=$(wc -l <log2.txt)for i in $(seq $log1_length); do     arg1="$(head -$i <log1.txt | tail -1)"    arg2="$(head -$(((i-1) % log2_length + 1)) <log2.txt | tail -1)"   # Case control structure to replace digit equivalent in words     case ${i} in        1) echo -n "The first color ";;        2) echo -n "The second color ";;        3) echo -n "The third color ";;        4) echo -n "The fourth color ";;        5) echo -n "The fifth color ";;        6) echo -n "The sixth color ";;        7) echo -n "The seventh color ";;        8) echo -n "The eighth color ";;        9) echo -n "The ninth color ";;       10) echo -n "The tenth color ";;       11) echo -n "The eleventh color ";;    esac     echo ${i}"$i${arg1} is ${arg2}" |  tr -d '0123456789'done

The output is as follows:

The first color Black is UglyThe second color Blue is NiceThe third color Brown is coolThe fourth color Copper is prettyThe fifth color Cyan is UglyThe sixth color Gold is NiceThe seventh color Gray is coolThe eighth color Green is pretty

Viewing all articles
Browse latest Browse all 5

Trending Articles