09-10-2012
I was trying go get this done in AWK, just for learning purposes, since the files are zipped i was using zcat
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
{ # print NF,NR,$0;
if ( ($(NF-1) != 0) && ($NF != 0) )
{if ($(NF-1) > $NF)
{percent=$(NF-1)/$NF-1;}
else
{percent=$NF/$(NF-1)-1;}
}
printf "%8.4f\%\n",percent*100;
if (percent > 0.05||percent < -0.05 ){exit 1;}
}'
Use code tags please, ty. Also try to use a more... (1 Reply)
Discussion started by: bosmat shani
1 Replies
2. UNIX for Dummies Questions & Answers
Hi Folks,
I know my code works, but I'm still a newbie at arrays and how they function.
Is there is shorter way to write my code? I'm taking averages in multiple files and concatenating output into 1 file.
TIA!
for file in *;
do
awk -F"\t" '{a1+=$1}{a2+=$2}{a3+=$3} {a4+=$4}{a5+=$5}... (1 Reply)
Discussion started by: calitiggr
1 Replies
3. Shell Programming and Scripting
Hi Guys,
Can someone please explain this code to me. I could figure out it's adding and comparing two fields but I am not sure which ones.
sort -t"|" -k3.1 /tmp/mpcashqc.xtr| awk -F"|" '{CHECKAMT+=$3;BATCHTOT=$4;\
items++}END{for(i in CHECKAMT) if (CHECKAMT!=BATCHTOT)... (6 Replies)
Discussion started by: nua7
6 Replies
4. Shell Programming and Scripting
#!/bin/ksh
set -x
FILENAME=$1
#To calculate debit and credit
DEBIT=`awk -F, '{value=$28 ;if(value<0) {debit+=value}} END {print debit}' $FILENAME`
CREDIT=`awk -F, '{value=$28 ;if(value>0) {credit+=value}} END {print credit}' $FILENAME`
#This part is not working since the debit value is... (2 Replies)
Discussion started by: selvankj
2 Replies
5. Shell Programming and Scripting
Hi,
I have a colon-separated file which contains names of users, among other details. My aim is to extract the line with the name and assign the name to a variable. A sample file is as follows --
ID: 123456
DEPARTMENT: xyz
NAME: Bar, Foo
Considering the Tabs between the colon and the... (6 Replies)
Discussion started by: Subu1987
6 Replies
6. Shell Programming and Scripting
sample data.file:
0,mfrh_green_screen,1454687485,383934,/PROD/G/cicsmrch/sys/unikixmain.log,37M,mfrh_green_screen,28961345,0,382962--383934
0,mfrh_green_screen,1454687785,386190,/PROD/G/cicsmrch/sys/unikixmain.log,37M,mfrh_green_screen,29139568,0,383934--386190... (7 Replies)
Discussion started by: SkySmart
7 Replies
7. Shell Programming and Scripting
can someone please help me spot and fix the issue with the following code:
awk -F, -v SEARCHPATT="(Wed|Tue)" -v ADDISTR="Mon|Tue|Wed|Thu|Fri|Sat|Sun" -vVF="$VALFOUND"
"BEGIN{ {D = D = 1
D = D = 2
}
$0 ~ "," VF "," {L = 1 ... (9 Replies)
Discussion started by: SkySmart
9 Replies
8. Shell Programming and Scripting
the following code works perfectly for me:
# AWK 1
gawk -F, '/,'${ThisMonthDOW}' '${ThisMonthMON}' :: '${ThisMonthYEA}',/ {
if (NF == 10)
... (6 Replies)
Discussion started by: SkySmart
6 Replies
9. UNIX for Beginners Questions & Answers
Dear experts,
I am a relative novice in the Unix and came across a very useful code that I regularly use for my research blindly. I am wondering if any of the professional members could kindly briefly explain to me what the code actually does?
Many thanks in advance
The script is
awk... (4 Replies)
Discussion started by: arsalane
4 Replies
Commands Reference, Volume 6, v - z
zcat_Command
Purpose
Expands a compressed file to standard output.
Syntax
zcat [ -n ] [ -V ] [ File ... ]
Description
The zcat command allows the user to expand and view a com-
pressed file
without uncompressing that file. The zcat command does not re-
name the
expanded file or remove the .Z extension. The zcat command
writes the
expanded output to standard output.
Flags
-n Omits the compressed file header from the compressed
file.
-V Writes the current version and compile options to stan-
dard error.
Parameters
File ... Specifies the compressed files to expand.
Return Values
If the zcat command exits with a status of 1 if any of the
following
events occur:
* The input file was not produced by the compress command.
* An input file cannot be read or an output file cannot be
written.
If no error occurs, the exit status is 0.
Exit Status
0 Successful completion.
>0 An error occurred.
Examples
To view the foo.Z file without uncompressing it, enter:
zcat foo.Z
The uncompressed contents of the foo.Z file are written to
standard
output. The file is not renamed.
Related Information
The compress command, pack command, uncompress command,
unpack command.
Commands in Operating system and device management.
________________________________________________________________________________
Commands Reference, Volume 6, v - z
zcat_Command
Purpose
Expands a compressed file to standard output.
Syntax
zcat [ -n ] [ -V ] [ File ... ]
Description
The zcat command allows the user to expand and view a com-
pressed file
without uncompressing that file. The zcat command does not re-
name the
expanded file or remove the .Z extension. The zcat command
writes the
expanded output to standard output.
Flags
-n Omits the compressed file header from the compressed
file.
-V Writes the current version and compile options to stan-
dard error.
Parameters
File ... Specifies the compressed files to expand.
Return Values
If the zcat command exits with a status of 1 if any of the
following
events occur:
* The input file was not produced by the compress command.
* An input file cannot be read or an output file cannot be
written.
If no error occurs, the exit status is 0.
Exit Status
0 Successful completion.
>0 An error occurred.
Examples
To view the foo.Z file without uncompressing it, enter:
zcat foo.Z
The uncompressed contents of the foo.Z file are written to
standard
output. The file is not renamed.
Related Information
The compress command, pack command, uncompress command,
unpack command.
Commands in Operating system and device management.