I write this bit of code to calculate the mean and variance for all the files in one directory and print the mean and variance in a separate folder but with the same file name.
if there is no data there it gives me an error as following
Quote:
awk: cmd. line:1: fatal: division by zero attempted
awk: cmd. line:1: fatal: division by zero attempted
still it creates the file but empty
then I need to combine all into one file. The way I have managed to do so for is
but I have some problems here and I would be grateful if you can help
when I am converting the files into columns, the files that are empty dont appear in my list
I need my file names to be there but with "-,-" or "NA, NA" instead of mean and variance
i was thing like this ... ( not sure whether my logic is write and dont know the syntax)
but I am not sure whether I have to change my loop or the awk bit for combining yet. any idea?
and then I am wondering whether I can optimise the code by combining those two bits together so instead of creating a whole set of files a another directory and then convert them to a single file, directly same them in a single file.
Thank you again in advance for you help
A-V
Last edited by vbe; 06-06-2012 at 11:32 AM..
Reason: typos
I was using -n instead of -s and it was not working and i was trying to use print instead of echo.
do you think it would be able to push the next awk into this code ?
so that I will be able to get it directly instead of going through making sets of files in a folder and then put them into a single file?
I was looking for them but didnt know what they are called
---------- Post updated at 11:14 AM ---------- Previous update was at 10:52 AM ----------
Corona688 : that is great way to present... i didnt think it would be possible to do like that and its very readable...
one step before that i count the mean and variance, I have another awk which gets the length to the entries per line which i managed to add in the other for-if loop
basically, the results from this line is being fed to the code but with your organized awk code, I dont know where they should go...
do they have to go before the
I am passing multiple files in awk & since one of the file is empty(say file3) so the same gets skipped & logic goes for toss. Need suggestion/help in checking and putting additional checks for the same
awk -F, 'FNR==1 {++filecounter}
filecounter==1 {KRL=$2;next}
filecounter==2... (8 Replies)
Is there a reliable way to deal with whitespace in array indicies?
I am trying to annotate fails in a database using a table of known fails.
In a begin block I have code like this:
# Read in Known Fail List
getline < "'"$failListFile"'"; getline < "'"$failListFile"'"; getline <... (6 Replies)
Korn Shell
I have hundreds of small files like below created every day. A midnight cron job moves them to the location /u04/temp/logs
But sometimes I have to manually move these files based a certain dates or time.
I have two basic requirements
1.Using mv command I want to move all .dat... (2 Replies)
Can someone please help me to learn how to deal with loops, arrays and grep?
I have two arrays (lets say I and j) each in a separate file
And have file with lines of data I need to extract, such as
Ruby Smith: some text here
Ruby Smith: some other text here
Ruby Brown: some text here
Ruby... (10 Replies)
Hi Friends,
I have two files as input with data that looks like this:
file1.txt
1
2
3
4
file2.txt
a,aa
b,bb
c,cc
d,dd
e,ee
f,ff
instead of me doing 2 while loops to get the combinations
while read line_file1 (2 Replies)
Hello, I am working on a coding project for a class and to test the program I have created, I have come up with 100 different test cases. The program takes four text files as input, so each of the test cases is contained in a folder with four files.
I have a folder called 'tests', within which... (1 Reply)
Hello, I'm a computer science major and I'm having problems dealing with file names with spaces in them. Particularly I'm saving a file name in a variable and then using the variable in a compare function i.e.
a='te xt.txt'
b='file2.txt'
cmp $a $b
If anyone could help me with this particular... (10 Replies)
Hi ,
My requirement is that i need to search for a number of strings in a log file and print them with line numbers.The search should be date wise.
The sample log file is :
Jan 17 02:45:34 srim6165 MQSIv500: (UKBRKR1P_B.LZ_
BENCHMARKS)BIP2648E: Message backed out to a queue; node... (6 Replies)
I have a process run weekly where I must convert data formats for about thirty files. I read a text file that provides all of the filenames and switch settings.
My perl code is:
for ($j = 1; $j <= $k; $j++)
{
open(FIN2,$fin2) || die "open: $!";
do other stuff
}
Every once in... (2 Replies)
I am trying to make a script that will replace backslashes in a file, but only if the occurance is a pathname. In the file, there are a lot of regular expressions as well, so I'm trying to preserve the integrity of those regular expressions, but convert Windows relative paths. I'm using bash and... (1 Reply)