08-20-2018
Your desired output changes every time you add a new post to this thread.
I suggested code in post #11 that gets rid of the need to need for the for loop you showed us in post #12 and produces the results that loop would produce inside the print_total() function.
The code that I suggested there worked perfectly with the earlier sample data you provided to produce the output you said you wanted in an earlier post in this thread. If you modified that code to produce a different output format and introduced a syntax error in the code as you did it, I can't help you without seeing how you modified the code. Since your requirements are constantly changing and since you haven't provided us with any sample input that could possibly produce the most recent output you're showing us, I'm not motivated to try to rewrite my suggestion again hoping to guess at what your next output format requirements might be.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi, I've written a shell function in bash that reads letters into an array, then outputs them in one column with:
for n in "${array}"; do
echo $n
done
I was wondering if anyone knew how i would transpose the letters that are output by the for loop. Right now my output is:
aabbcc... (4 Replies)
Discussion started by: myscsa2004
4 Replies
2. Shell Programming and Scripting
Hi,
I need to remove all lines from a file that do not start with numbers
For instance, if the first three characters on any line are not numbers, delete those lines
I've tried to do it with awk and it's not working, any ideas ?
Thanks (5 Replies)
Discussion started by: sfisk
5 Replies
3. UNIX for Advanced & Expert Users
I want to add letters A,B,C,… in front of every line of input while printing them out using PERL.
eg
A file is parsed as a cmd line arg and its context will be displayed as
A line1...
B line 2..
I tried this..but I want better and perfect solution!
!perl -p
my $counter;
BEGIN { $counter... (4 Replies)
Discussion started by: aadi_uni
4 Replies
4. Shell Programming and Scripting
Hi everyone,
I have a program that generates logs that contains sections like this:
IMAGE INPUT
81 0 0.995 2449470 0 1726 368 1 0.0635 0.3291
82 0 1.001 2448013 0 1666 365 1 0.0649 0.3235
83 0 1.009 2444822 0 1697 371 1 ... (3 Replies)
Discussion started by: euval
3 Replies
5. Shell Programming and Scripting
Hello,
I am working with a perl script that tries to find the average "frequency" in which lines are duplicated. So far I've only managed to find the way to count how many times the lines are repeated, the code is as follows:
perl -ae'
my $filename= $ENV{'i'};
open (FILE, "$filename") or... (10 Replies)
Discussion started by: acsg
10 Replies
6. Shell Programming and Scripting
I'm reading in numbers from a file and trying to add them together. Here is the code so far. I know the 1+2+3.... part is wrong. The file has five numbers in it with each number on its own line. The numbers are decimals if that matters. Thanks.
while read EachLine
do
echo $EachLine
done <... (6 Replies)
Discussion started by: AxlVanDamme
6 Replies
7. Shell Programming and Scripting
Hi,
Is there a tool somewhat parallel to rev, but which randomizes instead of reverses?
I've tried rl, but I can only get it to randomize words.
I was hoping for something like this
echo "hello" | ran
leolh
less simpler solutions are also welcome.
Sorry if the question is... (21 Replies)
Discussion started by: jeppe83
21 Replies
8. Shell Programming and Scripting
I have the following file
299899 chrX_299716_300082 196 78.2903 299991 chrX_299982_300000 18.2538 Tajd:0.745591 FayWu:-0.245701 T2:1.45
299899 chrX_299716_300082 196 78.2903 299991 chrX_299982_300000 18.2538 Tajd:0.745591 FayWu:-0.245701 T2:0.283
311027 chrX_310892_311162 300 91.6452... (2 Replies)
Discussion started by: jfern
2 Replies
9. UNIX for Beginners Questions & Answers
Hi there,
first of all this is not homework...this is a new type of exercise for practicing vocabulary with my students.
I have a file consisting of two columns, separated by a tab, each line consisting of a word and its definition, separated by a line break.
What i need is to replace a... (15 Replies)
Discussion started by: eldeingles
15 Replies
10. UNIX for Beginners Questions & Answers
The awk below executes and is close (producing the first 4 columns in desired). However, when I add the sum of $7, I get nothing returned. Basically, I am trying to combine all the matching $4 in f1 and output them with the average of $7 in each match. Thank you :).
f1
... (2 Replies)
Discussion started by: cmccabe
2 Replies
LEARN ABOUT CENTOS
afinitrate
AFINITSAMPLEFORMAT(3) AFINITSAMPLEFORMAT(3)
NAME
afInitSampleFormat, afInitByteOrder, afInitChannels, afInitRate - initialize audio data format for a track in an audio file setup
SYNOPSIS
#include <audiofile.h>
void afInitSampleFormat(AFfilesetup setup, int track, int sampleFormat,
int sampleWidth);
void afInitByteOrder(AFfilesetup setup, int track, int byteOrder);
void afInitChannels(AFfilesetup setup, int track, int channels);
void afInitRate(AFfilesetup setup, int track, double rate);
PARAMETERS
setup is a valid file setup returned by afNewFileSetup(3).
track specifies a track within the audio file setup. track is always AF_DEFAULT_TRACK for all currently supported file formats.
sampleFormat is a symbolic constant specifying the sample format for the audio data in the track. sampleFormat must be one of
AF_SAMPFMT_TWOSCOMP, AF_SAMPFMT_UNSIGNED, AF_SAMPFMT_FLOAT, or AF_SAMPFMT_DOUBLE.
sampleWidth is a positive integer specifying the number of bits for each sample in the track.
byteOrder is a symbolic constant specifying the byte order of the track. byteOrder must be one of AF_BYTEORDER_BIGENDIAN or
AF_BYTEORDER_LITTLEENDIAN.
channels is a positive integer specifying the number of channels in the track.
rate is a positive double-precision floating-point number specifying the sample rate of the track.
DESCRIPTION
afInitSampleFormat initializes the track to the specified sample format and sample width.
afInitByteOrder initializes the track to the specified byte order.
afInitChannels initializes the track to the specified number of channels.
afInitRate initializes the track to the specified sample rate.
ERRORS
afInitSampleFormat, afInitByteOrder, afInitChannels, and afInitRate can produce the following errors:
AF_BAD_FILESETUP setup represents an invalid file setup.
AF_BAD_TRACK track represents an invalid track identifier.
afInitSampleFormat can also produce the following errors:
AF_BAD_SAMPFMT sampleFormat does not represent a valid sample
format.
AF_BAD_WIDTH sampleWidth is not a valid sample width.
afInitByteOrder can also produce the following error:
AF_BAD_BYTEORDER byteOrder does not represent a valid byte order.
afInitChannels can also produce the following error:
AF_BAD_CHANNELS channels specifies an invalid number of channels.
afInitRate can also produce the following error:
AF_BAD_RATE rate specifies an invalid sample rate.
SEE ALSO
afNewFileSetup(3), afInitFileFormat(3), afInitCompression(3), afOpenFile(3)
AUTHOR
Michael Pruett <michael@68k.org>
Audio File Library 0.3.6 03/06/2013 AFINITSAMPLEFORMAT(3)