Read line containing String (Bash)
I have a file, and its something like this: Device: name1 random text Device: name2 random text Device: name3 random text I have a variable: MainComputer What I want to get (for each name, i have like 40 names): MainComputer -> name1 MainComputer -> name2 MainComputer -> name3 What I have: var="MainComputer" var1=$(awk '/Device/ {print $3}' file) echo "$var -> $var1" This only gives the arrow "->" and the link for the first variable, I want them for the other 40 variables... Thanks anyway! fedorqui Let me present you awk : $ awk '/Device/ {print $2}' file name1 name2 name3 This prints the