I need to execute the following grep query as an argument for konsole (the kde terminal)

grep -R -i -n -A 2 -B 2 --color=always -R "searchtext" * | less -R

works for the current terminal.

konsole --workdir `pwd` -e grep -R -i -n -A 2 -B 2 --color=always -R "searchtext" * | less -R

works, but the konsole window displays the grep query without less pipe.

Ideally I want konsole to spawn as seperate process with konsole &

and send the grep command with less as an argument for konsole -e

有帮助吗?

解决方案

You need to run the pipe in a shell.

konsole --workdir pwd -e bash -c 'grep -R -i -n -A 2 -B 2 --color=always -R "searchtext" * | less -R'
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top