通过system
或system2
运行shell命令的推荐方法是什么。
我发现自己总是必须逃避麻烦,才能正常工作。
有没有一种方法可以避免必须转义所有特殊字符?
示例:
bash$ # the following works fine
bash$ grep -i "something" some_file | grep -Po '(\d|-)+ (\d|:)+\.\d+'
# what I'd like
R> cmd <- magic(grep -i "something" some_file | grep -Po '(\d|-)+ (\d|:)+\.\d+')
R> system(cmd, inter = TRUE)