How to pass a string containing slashes to sed without treating it as a file? (No such directory or file)
0
votes
3
answers
907
views
I need to pass a string containing slashes to sed to extract some values from it, but when I try to do so it treats it as a directory/file and throws a "No such directory or file" error instead. I'm assuming this is because it reads it as a path and tries to find the file when it is not the intended effect. Example:
my_value="my/value"
operand="$($my_value | sed -n -e 's/^\(.*\)\/.*/\1/p')"
# Expected echo $operand : my
Note: I am new to bash scripts so this could be the wrong way to go about this
Asked by DMX David Cardinal
(103 rep)
May 11, 2020, 10:48 PM
Last activity: May 12, 2020, 05:54 AM
Last activity: May 12, 2020, 05:54 AM