Pipes का उपयोग
एक pipe एक bucket line जैसा है जहां एक kid अपने पास जो है वह अगले kid को पास करता है। हर command अपना छोटा काम करता है और result आगे सौंपता है।
In this page:
Syntax
command1 | command2 | command3
Pipes
Pipe operator | एक command के standard output को सीधे अगले के standard input से connect करता है, आपको छोटे commands को एक data-processing pipeline में chain करने देते हुए।
Bash दोनों commands को concurrently चलाता है, उनके बीच data streaming करते हुए। Pipelines shell scripting के सबसे powerful और idiomatic features में से एक हैं।
Note:
कई pipes को एक साथ chain करें, जैसे
cmd1 | cmd2 | cmd3, एक line में एक multi-step data pipeline बनाने के लिए।उदाहरण: Pipes
#!/bin/bash
printf "banana\napple\ncherry\n" | sort
echo "---"
printf "a\nb\nc\nd\n" | wc -l
Login to try C/C++/Java/PHP code in the editor
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
- यह उम्मीद करना कि एक pipe error messages (stderr) भेजेगा, जब सिर्फ standard output इससे गुजरता है।
- एक pipe के end पर एक
while readloop के अंदर variables set करना और loop के बाद उनकी उम्मीद करना, क्योंकि यह एक subshell में चलता है। cat file | grep xउपयोग करना जहांgrep x fileकाफी है।
🔒
Chapter Quiz — Complete all 14 topics to unlock
0/14 topics done
Complete these topics first: