# cat a.file
123123abc file2
274efcc4d8a0e8f61397be46bd4bfa37 file1
321 file1
# file="file1"
# grep -m 1 -oP "\K([\w]+) +$file" a.file
274efcc4d8a0e8f61397be46bd4bfa37 file1
How can I get the output 274efcc4d8a0e8f61397be46bd4bfa37 with the parameter file1 line, and only use grep command without | or other command like awk?
Is there grep -P have some other parameters for only print the match pattern \K([\w]+) such as the result is 274efcc4d8a0e8f61397be46bd4bfa37? Or Is there any implementation to get the result with grep only.