← Back to Bash Course | Chapter 3: Control Flow | Lesson 11 of 14

tee कमांड

tee एक T-shaped water pipe जैसा है: same पानी दोनों एक bucket में और आगे next place की तरफ flow करता है। आप output को एक file में save करते हैं और फिर भी इसे screen पर देखते हैं।

In this page:

  1. tee
Syntax
bash
command | tee file_name
command | tee -a file_name

tee

tee standard input से पढ़ता है और इसे एक साथ एक file में और वापस standard output में लिखता है, आपको terminal में इसे देखते हुए भी output को एक log में save करने देते हुए।

यह अक्सर एक pipeline के बीच में रखा जाता है। tee -a overwrite करने के बजाय file में append करता है।

Note: command | tee log.txt उपयोग करें output को live देखने के लिए और साथ ही इसे बाद के लिए save करने के लिए।

उदाहरण: tee

bash
#!/bin/bash
echo "Important message" | tee log.txt
echo "--- contents of log.txt ---"
cat log.txt
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. #}
आम गलतियां
  1. -a भूल जाना, इसलिए tee file हर बार file overwrite करता है।
  2. यह उम्मीद करना कि tee errors लिखेगा, जब यह सिर्फ standard output copy करता है।
  3. sudo cmd > file उपयोग करना और redirect के पास root rights होने की उम्मीद करना; cmd | sudo tee file उपयोग करें।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.