This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
linux:pipe [2018/03/20 15:49] – [Pipe to a file] tmade | linux:pipe [2022/02/16 04:30] – [Error-handling] tmade | ||
---|---|---|---|
Line 7: | Line 7: | ||
==== Pipe to a file ==== | ==== Pipe to a file ==== | ||
- | (stdin) | + | (stdin) |
- | (stdout) 1 #Standart | + | (stdout) 1 #Standard |
- | (stderr) 2 #Standart | + | (stderr) 2 #Standard |
- | > # | + | > # |
- | 1> # | + | 1> # |
- | 2> # | + | 2> # |
Examples: | Examples: | ||
- | ls /opt/ /otherfile > list 2>& | + | ls /opt/ /otherfile > file 2>& |
- | echo "This is a test" 1> / | + | sudo -lU ${USER} > /dev/null 2>& |
+ | ls /opt /otherfile 2> / | ||
+ | programm &> | ||
+ | echo "This is a test" 1> / | ||
ls xyz > info.txt 2> error.txt | ls xyz > info.txt 2> error.txt | ||
ls /opt / | ls /opt / | ||
- | 2> / | + | 2> / |
- | 2>> | + | 2>> |
| | ||
**Explication check:** | **Explication check:** | ||
man -Len -Pless\ +/ | man -Len -Pless\ +/ | ||
- | | ||
==== Execution Dependency ==== | ==== Execution Dependency ==== | ||
command1 && command2 | command1 && command2 | ||
command1 || command2 | command1 || command2 | ||
+ | command1 && command2 || command3 | ||
| | ||
==== Error-handling ==== | ==== Error-handling ==== | ||
To check if a process is running/ return code: | To check if a process is running/ return code: | ||
- | SERVICE_NAME=apache2 | + | |
- | + | ||
(ps -ef | grep $SERVICE_NAME | (ps -ef | grep $SERVICE_NAME | ||
ps -ef | grep $SERVICE_NAME | grep -v grep && RESULT=running || RESULT=error | ps -ef | grep $SERVICE_NAME | grep -v grep && RESULT=running || RESULT=error |