Ana Sayfa / Linux / Bash Script / Bash Script Pipelines

Bash Script Pipelines

Using |&

|& connects standard output and standard error of the first command to the second one while | only connectsstandard output of the first command to the second command.
In this example, the page is downloaded via curl. with -v option curl writes some info on stderr including , thedownloaded page is written on stdout. Title of page can be found between and .

curl -vs '' |& awk '/Host:/{print}
/<title>/{match($0,/<title>(.*)<\/title>/,a);print a[1]}'

Output is:

> Host:

But with | a lot more information will be printed, i.e. those that are sent to stderr because only stdout is piped to the next command. In this example all lines except the last line (Google) were sent to stderr by curl:

* Hostname was NOT found in DNS cache
* Trying
* Connected to ( port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host:
> Accept: */*
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Date: Sun, 24 Jul 2016 19:04:59 GMT
< Expires: -1
< Cache-Control: private, max-age=0
< Content-Type: text/html; charset=ISO-8859-1
< P3P: CP="This is not a P3P policy! See for more info."
< Server: gws
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< Set-Cookie: NID=82=jX0yZLPPUE7u13kKNevUCDg8yG9Ze_C03o0IMEopOSKL0mMITEagIE816G55L2wrTlQwgXkhq4ApFvvYEoaWFoEoq2T0sBTuQVdsIFULj9b2O8X35O0sAgUnc3a3JnTRBqelMcuS9QkQA;
expires=Mon, 23-Jan-2017 19:04:59 GMT;
path=/;; HttpOnly
< Accept-Ranges: none
< Vary: Accept-Encoding
< X-Cache: MISS from jetsib_appliance
< X-Loop-Control: 81E4F9836653D5812995BA53992F8065
< Connection: close
{ [data not shown]
* Closing connection 0

Bunada Göz Atın

PHP Types

Type Comparison There are two types of comparison: loose comparison with == and strict comparison …

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir