I have this script script.sh
:
#!/bin/bash
file_path=$1
result=$(grep -Po 'value="\K.*?(?=")' $file_path)
echo $result
and this file text.txt
:
value="a"
value="b"
value="c"
When I run ./script.sh /file/directory/text.txt
command, the output in the terminal is the following:
a b c
I understand what the script does, but I don't understand HOW it works, so I need a detailed explanation of this part of command:
-Po 'value="\K.*?(?=")'
If I understood correctly, \K
is a Perl command. Can you give me an alternative in shell (for example with awk
command)?
Thank you in advance.