I am trying to pass a variable as below, but it does not work properly:
$ cat test.txt
/home/TEST/file1
/home/TEST/file2
/home/TEST/file3
$ export x=TEST
$ echo x
x
$ grep -s '' test.txt | grep -oP '(?<=/$x/).*(?=)'
$
whilst,the output of the grep command should be as following:
$ grep -s '' test.txt | grep -oP '(?<=/TEST/).*(?=)'
file1
file2
file3
Would you please advise?