Code: Select all
Tina
Steve
Mary
Code: Select all
cat /pathtofile/name.txt | head -2 | tail -1
Code: Select all
Steve 12
Mary 14
Tina 18
Code: Select all
cat /pathtofile/name.txt | head -2 | tail -1 | cat/pathtofile/records.txt | grep "?"
Code: Select all
Tina
Steve
Mary
Code: Select all
cat /pathtofile/name.txt | head -2 | tail -1
Code: Select all
Steve 12
Mary 14
Tina 18
Code: Select all
cat /pathtofile/name.txt | head -2 | tail -1 | cat/pathtofile/records.txt | grep "?"
grep Steve data.txt
? Is the issue that the data file might contain more or other names but you need all from name.txt? Then something like for NAME in $(cat name.txt); do grep "$NAME" data.txt; done
. Are the name.txt and data.txt file guaranteed to have the same names even if in possibly different order? If so, sort
is going to be part of the best answer.Code: Select all
$ cat data.txt
Steve 12
Mary 14
Tina 18
| head -3
after the sort). That is,Code: Select all
$ sort -k2 -r data.txt
Tina 18
Mary 14
Steve 12
Code: Select all
$ sort -k2 -r data.txt | cut -f1
Tina
Mary
Steve
Code: Select all
$ sort -k2 -r data.txt | cut -f1 | xargs
Tina Mary Steve
sort
is not the answer then I still don't get it (enough); don't see where/how the separate name.txt comes into things.Jator wrote: ⤴Sat Jul 03, 2021 8:45 amCode: Select all
cat /pathtofile/name.txt | head -2 | tail -1 | cat/pathtofile/records.txt | grep "?"
grep $(readline 2 name.txt) records.txt
grep $(cat name.txt | head -2 | tail -1) records.txt