I have a file that I need to look up a value by key using a shell script. The file looks like:
HereIsAKey This is the value
How can I do so
If the file is unsorted, lookups will be slow:
my_var=$( awk '/^HereIsAKey/ { $1=""; print $0; exit}' value-file )
If the file is sorted, you can get a faster lookup with
my_var=$( look HereIsAkey value-file | cut -d ' ' -f 2- )