Find all instances of word occurring in a file
问题 Using bash I was wondering how I can find all instances of a word which starts with text, store it as a variable and print it out. For example if this was my file test.conf $temp_test test $1234_$temp $temp_234 My output would be as follows: $temp_test $temp_234 Can anyone tell me how this might be possible? This is the closest I could get so far. while read NAME do echo "$NAME" done < test.conf 回答1: You can just use grep with right regex: grep '^ *$temp' test.conf $temp_test $temp_234 UPDATE