Need to remove leading space from awk statement space from calculation


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Need to remove leading space from awk statement space from calculation
# 1  
Old 08-16-2013
Need to remove leading space from awk statement space from calculation

I created a awk state to calculate the number of success however when the query runs it has a leading zero. Any ideas on how to remove the leading zero from the calculation?

Here is my query:
Code:
cat myfile.log | grep [0-9] | awk '{print $2,$3,$7,$11,$15,$19,$23,$27,$31,$35($19/$15*100)}'
02:00:00 1903385 1903132 251 781 762 16 0 0 097.5672


Last edited by Scott; 08-17-2013 at 12:04 AM.. Reason: Code tags
# 2  
Old 08-17-2013
If I had to guess, I'd say field $35 contained a 0, and all you need to do is add a comma between that and the calculation.

Alternatively:
Code:
awk '/[0-9]/ {print $2, $3, $7, $11, $15, $19, $23, $27, $31, $35, $19/$15*100}' myfile.log

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How do I remove leading spaces in UNIX when count of space character is not fixed? Example below-

Script showStreamsGLIS$reg.$env.ksh gives me output as below- Job Stime Etime Status ExitCode GLIS-AS-S-EFL-LOCK-B ----- ----- OI 103313880/0 GLIS-ALL-Q-EOD-FX-UPDT-1730-B ----- ----- TE 0/0 GLIS-TK-S-BWSOD-B ... (8 Replies)
Discussion started by: Tanu
8 Replies

2. Shell Programming and Scripting

Preserve leading white space

I have about 350 programs in which I have to add 2 lines; one before and one after a specfic line. The following script does the job except that I lose the indentation. #!/usr/bin/bash while read line ... (8 Replies)
Discussion started by: jgt
8 Replies

3. Shell Programming and Scripting

Fixed with file- removing leading zeros and adding the space

Hi All, i have a fixed width file , where each line is 3200 length. File: 1ABC 1111 2222 3333 000012341 1001 2ABC 1111 2222 3333 000012342 1002 3ABC 1111 2222 3333 000112343 1003 1DEF 5555 4444 9696 000012344 1004 2DEF 5555 2323 8686 000012345 1005 3DEF 5555 1212 7676 000012346 1006 ... (1 Reply)
Discussion started by: mechvijays
1 Replies

4. Shell Programming and Scripting

Compare strings with space in if statement

DEV> vi test_if_statement.sh "test_if_statement.sh" 9 lines, 205 characters proc_out="Normal completion" proc_out_comp="Normal completion" echo 'proc_out:'$proc_out echo 'proc_out_comp:'$proc_out_comp if then echo 'match' else echo 'no_match' fi ~ ~ ~ ~ ~ ~ ~ ~ ~ (4 Replies)
Discussion started by: cartrider
4 Replies

5. UNIX for Dummies Questions & Answers

Changing only the first space to a tab in a space delimited text file

Hi, I have a space delimited text file but I only want to change the first space to a tab and keep the rest of the spaces intact. How do I go about doing that? Thanks! (3 Replies)
Discussion started by: evelibertine
3 Replies

6. Fedora

Need to incrwase PHYSICAL VOLUME space on hard drive with free space on it

Hi, I run Fedora 17. I created a physical volume of 30GB on a disk with 60GB of space so there is 30GB of free space. On the physical volume, I created my volume group and logical volumes. I assigned all the space in the physical volume to my volume group. I need to add the 30GB of free space... (1 Reply)
Discussion started by: mojoman
1 Replies

7. Shell Programming and Scripting

Awk or If/statement Calculation Problem

#!/bin/sh CURRENTSTATE=2 CSVCSTATE=2 LASTSTATECHANGE=8 CSVCSTATEAGE=5 if (($CURRENTSTATE==$CSVCSTATE))&&(($LASTSTATECHANGE>=$CSVCSTATEAGE)) echo GREAT fi returns: ./aff: line 12: syntax error near unexpected token `fi' ./aff: line 12: `fi' what am i doing wrong here? (6 Replies)
Discussion started by: SkySmart
6 Replies

8. Shell Programming and Scripting

Calculate total space, total used space and total free space in filesystem names matching keyword

Good afternoon! Im new at scripting and Im trying to write a script to calculate total space, total used space and total free space in filesystem names matching a keyword (in this one we will use keyword virginia). Please dont be mean or harsh, like I said Im new and trying my best. Scripting... (4 Replies)
Discussion started by: bigben1220
4 Replies

9. UNIX for Advanced & Expert Users

wake up user space thread from kernel space ISR

Hello, I'm searching for a proper way to let the kernel space ISR(implemented in a kernel module) wake up a user space thread on a hardware interrupt. Except for sending a real-time signal, is it possible to use a semaphore? I've searched it on google, but it seems impossible to share a... (0 Replies)
Discussion started by: aaronwong
0 Replies

10. SCO

Swap space calculation

Hi every one. I have a client with a Unixware 7.1.3 system. 4GB Ram 2 x Xeon CPU's 4 x 147GB scsi Raid 5 Config 1 x 147GB Scsi spare drive Running a database application on top of Unixware What is the formula you use to determine what the size of the swap file is suppose to be ?. ... (5 Replies)
Discussion started by: linuxjunkie
5 Replies
Login or Register to Ask a Question