tee

Incorrect results with bash process substitution and tail?

孤街浪徒 提交于 2019-12-04 00:19:24
Using bash process substitution, I want to run two different commands on a file simultaneously. In this example it is not necessary but imagine that "cat /usr/share/dict/words" was a very expensive operation such as uncompressing a 50gb file. cat /usr/share/dict/words | tee >(head -1 > h.txt) >(tail -1 > t.txt) > /dev/null After this command I would expect h.txt to contain the first line of the words file "A", and t.txt to contain the last line of the file "Zyzzogeton". However what actually happens is that h.txt contains "A" but t.txt contains "argillaceo" which is about 5% into the file. Why

【Linux常见命令】tee命令

随声附和 提交于 2019-12-03 20:58:55
tee - read from standard input and write to standard output and files tee命令用于读取标准输入的数据,并将其内容输出成文件。 tee指令会从标准输入设备读取数据,将其内容输出到标准输出设备,同时保存成文件。 语法:   tee [OPTION]... [FILE]...    tee [- ai ][-- help ][-- version ][文件...] 参数 : -a或--append  附加到既有文件的后面,而非覆盖它. [root@oldboy oldboy]# cat new.txt|tee ls_list_tee.txt -a # -a相当于追加重定向 1-user01 2-user02 3-user03 4-user04 5-user05 [root@oldboy oldboy]# cat ls_list_tee.txt date_str.txt ls_list.txt name.txt new new.txt number.txt school.txt seq_1.txt sort_c.txt sort_t.txt sort_test.txt split_test.txt test.sh test.txt uniq.txt 1-user01 2-user02 3-user03 4-user04

Unix: confusing use of the Tee -command

折月煮酒 提交于 2019-12-03 16:16:57
问题 Manual states that the tee is a "pipe fitting"-tool. The cases [1] confuse me: 1. case echo "foo bar" | sudo tee -a /path/to/some/file 2. case :w !sudo tee % It is hard to understand the logic of tee from the cases. How does the tee work? 回答1: tee is normally used to split the output of a program so that it can be both displayed and saved in a file. The command can be used to capture intermediate output before the data is altered by another command or program. The tee command reads standard

KeyAttestation in Android Nougat API 24

时光怂恿深爱的人放手 提交于 2019-12-03 13:05:55
问题 I read about the new key attestation API in Android N and wanted to test it but I'm missing some classes. The key attestation is described here: https://developer.android.com/preview/features/key-attestation.html In the first code snipped a Attestation class is used which can't be found with the targetAPI set to API 24. Attestation hardwareKeyAttestation = new Attestation(attestationCert); Do I miss here anything? Do I need proprietary libraries? 来源: https://stackoverflow.com/questions

MySQL 使用tee记录语句和输出日志

这一生的挚爱 提交于 2019-12-03 11:58:34
在mysql命令行中,使用tee命令,可以记录语句和输出到指定文件。在debugging时会很有用。 每执行一条语句,mysql都会讲执行结果刷新到指定文件。Tee功能只在交互模式生效。 mysql> tee d:\mylearn\learn_Mysql\20191104.sql 关闭日志记录的功能; mysql>notee 来源: https://www.cnblogs.com/yachao1120/p/11795247.html

use tee command to redirect output to a file in a non-existent dir

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to use the tee command to redirect output to a file, and I want the file to be created in a dir which is yet to be created. date | tee new_dir/new_file when new_dir is not there, the tee command fails saying tee: new_dir/new_file: No such file or directory If I create the new_dir prior to running the tee command, then it works fine, but for some reason I don't want to create the new_dir manually, is it possible to create the new_dir with the tee command ? 回答1: No. You'll have to create the directory before running tee . 回答2:

tee and exit status

我与影子孤独终老i 提交于 2019-12-03 05:17:48
is there an alternative to "tee" which captures STDOUT/STDERR of the command being executed and exits with the same exit status as the processed command. Something as following: eet -a some.log -- mycommand --foo --bar Where "eet" is an imaginary alternative to "tee" :) (-a means append, -- separates the captured command) It shouldn't be hard to hack such a command but maybe it already exists and I'm not aware of it? Thanks. Here's an eet . Works with every Bash I can get my hands on, from 2.05b to 4.0. #!/bin/bash tee_args=() while [[ $# > 0 && $1 != -- ]]; do tee_args=("${tee_args[@]}" "$1")

KeyAttestation in Android Nougat API 24

…衆ロ難τιáo~ 提交于 2019-12-03 03:27:19
I read about the new key attestation API in Android N and wanted to test it but I'm missing some classes. The key attestation is described here: https://developer.android.com/preview/features/key-attestation.html In the first code snipped a Attestation class is used which can't be found with the targetAPI set to API 24. Attestation hardwareKeyAttestation = new Attestation(attestationCert); Do I miss here anything? Do I need proprietary libraries? 来源: https://stackoverflow.com/questions/38482705/keyattestation-in-android-nougat-api-24

shell tee shell 管道和tee使用时获取前面命令返回值

这一生的挚爱 提交于 2019-11-30 10:14:17
这样能获取到前面命令的返回值 sh a.sh | tee >>a.log aa= ${PIPESTATUS[0]} if [ $aa -ne 0 ] then echo "aaaaaaaaaaaaaaaa" fi #!/bin/bash source ./get_config.sh source ./get_date.sh #set -xv #exec 1>${etlHome}/LOG/ODS/${data_date}/xxx.log 2>&1 # $1 为ods、bds $2为 #测试 传递参数 #etlSys="ods" #etlJob="P_CRD_CC_COMM_STABILITY_SCORE_RES" #发布时,参数为传递进来的 etlSys=$1 etlJob=$2 etldte=$3 #传递近来的参数转大写 etlSys=${etlSys^^} etlJob=${etlJob^^} #传递近来的参数转小写 etlSysL=${etlSys,,} etlJobL=${etlJob,,} etlHome="/dw/workflow" currentTime=$(date "+%G%m%d%H%M%S%N") binPath="${etlHome}/APP/${etlSys}/${etlJob}/bin" sqlPath="${etlHome}/APP/${etlSys}/

How to redirect stdout+stderr to one file while keeping streams separate?

泪湿孤枕 提交于 2019-11-30 03:40:16
Redirecting stdout+stderr such that both get written to a file while still outputting to stdout is simple enough: cmd 2>&1 | tee output_file But then now both stdout/stderr from cmd are coming on stdout. I'd like to write stdout+stderr to the same file (so ordering is preserved assuming cmd is single threaded) but then still be able to also separately redirect them, something like this: some_magic_tee_variant combined_output cmd > >(command-expecting-stdout) 2> >(command-expecting-stderr) So combined_output contains the both with order preserved, but the command-expecting-stdout only gets