I'm trying to make a function in .bashrc to run this command:
lspci -kvnn | sed -n '/VGA/,/^$/ p'
, where VGA would be substituted with the first argument $1.
This is what I came up with:
lsp(){
sed_str="'/$1/,/^$/ p'"
echo $sed_str
lspci -kvnn | sed -n $sed_str
return
}
export -f lsp
I cannot understand why the function fails, the echo $sed_str (there for troubleshooting) output looks exactly the same as the regex in the first command. Still sed is complaining:
[user@linux ~]$ lsp VGA
'/VGA/,/^$/ p'
sed: -e expression #1, char 1: unknown command: `''
[user@linux ~]$
There's probably something obvious I'm not seeing here.
Kernel and shell:
uname -r -> 5.8.14-arch1-1
echo $SHELL -> /bin/bash