> ## Content Index
> Fetch the complete content index at: https://kudithipudi.org/llms.txt
> Use this file to discover other available public pages before exploring further.

# HOW TO : pipe results between commands when using sudo
- URL: https://kudithipudi.org/how-to-pipe-results-between-commands-when-using-sudo/
- Published: 2015-12-13T05:27:05.000Z
- Updated: 2015-12-13T05:27:05.000Z
- Description: Let’s say you are running a command as sudo and need to pass the output to a different command using pipe, you would run sudo command1...
- Author: admin
- Tags: HOWTO, Linux, Technology, Uncategorized, #wp, #wp-post, #Import 2026-08-23 02:32

Let’s say you are running a command as sudo and need to pass the output to a different command using pipe, you would run

```
sudo command1 | command 2
```

this usually results in the following error

```
-bash: /command2: Permission denied
```

The trick to fix is to run sudo with -c and enclose the commands in ” like below

```
sudo -c 'command1 | command 2'
```

essentially you are opening a shell with sudo and running the commands