Quantcast
Channel: Link variables between two text files - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 5

Link variables between two text files

$
0
0

The following explanation is just a representation for what I would like to achieve.

I have two text files: The first text file log1.txt contain the following entries:

BlackBlueBrownCopperCyanGoldGrayGreen

The second text file log2.txt contain the following entries:

UglyNicecoolpretty

I would like to read both texts at the same time and generate the following output:

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

How can I achieve the previous output using bash or shell? I tried to apply two loops at the same time :for loop" and/orwhile loop` but did not work! For example, I tried this awkward code:

#!/bin/bashwhile IFS= read -r line; do    for ii in $(cat log1.txt); doecho "The first color "$i "is" $iidone <log2.txtdone

I have no idea or clue how to change between "first color", "second color", ….etc


Viewing all articles
Browse latest Browse all 5

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>