Confused over results using "tee" in piped command
First post here, so hopefully all guidelines are followed, and thanks in advance for any replies.
I'm working on a shell script(BASH) that processes a csv file and performs various tasks with the data. All is well, except I want to use 'tee' to send output from 'wc' to a file as well as pipe it to 'cut'. What I'm trying to accomplish is a) tally the record count from a list of files, and b) send the details of 'wc' to an output file.
This code successfully tallies the record count, but obviously isn't sending the output from 'wc' to an output file:
I then insert a 'tee' into the mix and suddenly the setting of the vCount variable is 'broken'.
Here's the modified code:
I'd paste the results, but since this should run as is, suffice it to say that vCount is not getting set, and is blank.
You've used 'tee' without giving it any filenames, which is effectively the same as 'cat'. The one file it writes by default, stdout, you've redirected to a file, leaving nothing left for cut to get.
If you want tee to actually put the output into several files, don't redirect it, just tell which file you want
The -a is for append.
---------- Post updated at 01:12 PM ---------- Previous update was at 01:10 PM ----------
What I'd actually do, though?
Much more efficient, using nearly pure builtins except wc.
Thanks, but I wanted the names of the files included in the details. Your suggestion added only the record count, but not the name of the file. Here's the final segment of code that worked:
I'm on Ubuntu 14.04 and I manually updated my coreutils so that "tee" is now on version 8.27
I was running a script using bash where there is some write to pipe error at some point causing the tee command to exit abruptly while the script continues to run. The newer version of tee seems to prevent... (2 Replies)
Hi,
How to append content into a file using tee command
echo " file1 is archived"| tee -a archive.txt
echo " file2 is archived"| tee -a archive.txt
echo " file3 is archived"| tee -a archive.txt
how to append content as new rows in the archive.txt
Thanks,
Srinadh. (4 Replies)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
08:29 < xsi> >{respo,nd}.php bash: {respo,nd}.php: ambiguous redirect
08:31 < geirha> xsi: maybe you want tee
So I was advised to do so. And I can't create two OR MORE files at once with {a,b,c,d,e,f}.php
(which I quickly now need to create and to learn to create in the future to quickly... (2 Replies)
I have code fragment like
{
aa
bb
cc
} > $LOG
aa bb cc, all call function "ff", I want "ff" to print on the screen,but others do not print on the scree, is there a method? I can't use "tee", becasue tee I meet the write "error"
ff()
{
echo "hello"
} (2 Replies)
Greetings, everyone.
1. The problem statement, all variables and given/known data:
I'm running into a problem with my program concerning the actual output it does. When I open the file that gets the output, it contains
a large number of hex(?) variables and not what the user wants. The... (0 Replies)
BACK STORY:
I have a script build.py . (It's for creating the ISO file for a special edition of Swift Linux.) This build.py script executes the mintConstructor.py script that I use to modify the Regular Swift Linux ISO to get the special edition Swift Linux ISO. The lines of the script that... (2 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Im trying to check if a series of directory exists and if not create them, and am having issues. All the instances of test return with the error "test:
#!/bin/bash
location_Parent=~/Documents/sight_of_sound
location_IMG=~/Documents/Sight_of_sound/IMG
location_AUD=~/Documents/Sight_of_sound/AUD... (4 Replies)
Hello,
I am uning IRIX64. I need to do an ls - 1 (one) command in order to get a one colum listing of the contents of a non current directory:
t01:~ > ls -1 /scratch/u118807/reconstruct
./
../
fr000202.rec
fr000202.sin
input_files/
input_files.tar
sin000000.rec
sin000000.sin... (8 Replies)