Vibhu
Vibhu

Reputation: 61

Linux command output not getting redirected

Why doesn't the output get redirected in this case. The user doesn't have permission to write in /proc hence the error but why the error isn't going to /dev/null?

$echo "core_%e.%p" > /proc/sys/kernel/core_pattern 2>&1 > /dev/null

-bash: /proc/sys/kernel/core_pattern: Permission denied

Upvotes: 2

Views: 233

Answers (2)

pasaba por aqui
pasaba por aqui

Reputation: 3519

Try with:

echo "core_%e.%p" 2>/dev/null > /proc/sys/kernel/core_pattern 2>&1

that will send stdout and stderr to "core_pattern", if possible, if not, ends without message.

Upvotes: 1

Vibhu
Vibhu

Reputation: 61

works too:

bash -c 'echo "core_%e.%p" > /proc/sys/kernel/core_pattern' > /dev/null 2>&1

Upvotes: 0

Related Questions