Suppose I have a file that contains, among many other things,
\command{arg1,arg2,arg3}
(arguments been paths, expressed with /
, .
, characters and numbers)
But that a user can as well call it with
\command{arg1,
arg2 ,
arg3
}
That is, on several lines and with superfluous spaces.
I'd like to find a regular pattern to include in a shell script so that n variables will contain the n arguments. How to proceed ?
I managed to write
echo "\command{arg1,
arg2 ,
arg3
}" | sed -n -e 's/\\command//p' | sed 's/,/\n/' | sed 's/{\|}//'
but that only outputs arg1
, and I'm not even sure on how to store it in a variable.
Related:
- matching the text between parenthesis in a multiline text
- finding strings between two characters
- outputing only the part that matches the regular expression
- how to delete everything between a group of brackets
But I was not able to combine all those ingredients to get what I want.
grep
manual and get a better insight on what theZ
parameter!