Sponsored Content
Full Discussion: Stuck with awk !!!
Top Forums UNIX for Advanced & Expert Users Stuck with awk !!! Post 302853451 by Scott on Saturday 14th of September 2013 12:51:24 PM
Old 09-14-2013
Use printf "%.2f" to round to 2 decimal places (assuming that's your only problem, which I can see from the output).
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

stuck....!

I have been busy reading away on devices and filesystems and I am stuck on a particular subject matter.. I'm not understanding the concept behind mknod mkfifo makedev or related commands.. can anyone shed some light on the subject.! any feedback welcome! moxxx68 (0 Replies)
Discussion started by: moxxx68
0 Replies

2. Shell Programming and Scripting

Got stuck so plz help

I'm having problem writing a shell script using bash that takes a file as an argument. The script should be able to determine what permissions the owner, group and everybody has for the file passed in. could anyone plz help me out. (3 Replies)
Discussion started by: boris
3 Replies

3. UNIX for Dummies Questions & Answers

stuck and confused

#!/bin/bash echo $1 | cat - $2 >> /tmp/$$ && mv /tmp/$$ $2 im trying to get the first argument to go in the middle of the second argument which is a file, anyone any ideas. i have only managed to get it to go on the end or the front. been fiddling about with wc -l, i get the number of lines... (5 Replies)
Discussion started by: iago
5 Replies

4. Programming

I'm stuck :(

Suppose that I have some data: 12,30 12,45 2,3 7,8 3,9 30, 8 45,54 56,65 Where (a,b) indicates that a is connected to b. I want to get all connected nodes to one point. For instance, the output of the above example should be something like: Group 1 2,3 3,9 Group 2 12,30 12,45... (4 Replies)
Discussion started by: Legend986
4 Replies

5. AIX

really stuck- need to get a variable within a variable- AWK

Hi all, I have been struggling with this all day, and it is key to a conversion database I have to write. The data converts the information out of an array using AWK, and basically all I have to do is figure out how to get the value of a variable inside a variable. Right now at its... (11 Replies)
Discussion started by: jeffpas
11 Replies

6. Shell Programming and Scripting

help! im stuck..

I want to search for the line with the group name and add the user into the group. The file format is the same as /etc/group The code i wrote is egrep "^$newGID" $group >/dev/null FS=":" oldData=awk -F: '{print $3}' newData= "$oldData,$newUser" sed -n $4/$newData $group but a friend... (1 Reply)
Discussion started by: cherrywinter
1 Replies

7. Shell Programming and Scripting

I am stuck in my script

Hi All I have script that find 777 dir with specific extension like .php .Now after finding all 777 directory i will place in httpd.conf using a directory directive ,Now i was not do that,if directory entry exitst in httpd.conf then script ignor it dont show me at stdout else if it dont find... (2 Replies)
Discussion started by: aliahsan81
2 Replies

8. Shell Programming and Scripting

awk getting stuck after BEGIN

I am beginner in awk awk 'BEGIN{for(i=1;(getline<"opnoise")>0;i++) arr=$1}{print arr}' In the above script, opnoise is a file, I am reading it into an array and then printing the value corresponding to index 20. Well this is not my real objective, but I have posted this example to describe... (1 Reply)
Discussion started by: akshaykr2
1 Replies

9. Linux

Stuck in pthread_cond_signal()

I am developing a multi-threaded library that helps the transformation of messages between threads in different processes using shared memory. I am using the pthreads condition facility in order to synchronize access to the shared memory slots through which the messages are passed. My test... (2 Replies)
Discussion started by: dhzdh
2 Replies

10. Homework & Coursework Questions

stuck on assignment

I was given this to do, Write a Shell script to automatically check that a specified user is logged in to the computer. The program should allow the person running the script to specify the name of the user to be checked, the frequency in seconds at which the script should check. If a... (1 Reply)
Discussion started by: operator
1 Replies
PRINTF(3S)																PRINTF(3S)

NAME
printf, fprintf, sprintf - formatted output conversion SYNOPSIS
#include <stdio.h> printf(format [, arg ] ... ) char *format; fprintf(stream, format [, arg ] ... ) FILE *stream; char *format; sprintf(s, format [, arg ] ... ) char *s, format; DESCRIPTION
Printf places output on the standard output stream stdout. Fprintf places output on the named output stream. Sprintf places `output' in the string s, followed by the character `'. Each of these functions converts, formats, and prints its arguments after the first under control of the first argument. The first argu- ment is a character string which contains two types of objects: plain characters, which are simply copied to the output stream, and conver- sion specifications, each of which causes conversion and printing of the next successive arg printf. Each conversion specification is introduced by the character %. Following the %, there may be - an optional minus sign `-' which specifies left adjustment of the converted value in the indicated field; - an optional digit string specifying a field width; if the converted value has fewer characters than the field width it will be blank-padded on the left (or right, if the left-adjustment indicator has been given) to make up the field width; if the field width begins with a zero, zero-padding will be done instead of blank-padding; - an optional period `.' which serves to separate the field width from the next digit string; - an optional digit string specifying a precision which specifies the number of digits to appear after the decimal point, for e- and f-conversion, or the maximum number of characters to be printed from a string; - the character l specifying that a following d, o, x, or u corresponds to a long integer arg. (A capitalized conversion code accom- plishes the same thing.) - a character which indicates the type of conversion to be applied. A field width or precision may be `*' instead of a digit string. In this case an integer arg supplies the field width or precision. The conversion characters and their meanings are dox The integer arg is converted to decimal, octal, or hexadecimal notation respectively. f The float or double arg is converted to decimal notation in the style `[-]ddd.ddd' where the number of d's after the decimal point is equal to the precision specification for the argument. If the precision is missing, 6 digits are given; if the precision is explicitly 0, no digits and no decimal point are printed. e The float or double arg is converted in the style `[-]d.ddde+-dd' where there is one digit before the decimal point and the number after is equal to the precision specification for the argument; when the precision is missing, 6 digits are produced. g The float or double arg is printed in style d, in style f, or in style e, whichever gives full precision in minimum space. c The character arg is printed. Null characters are ignored. s Arg is taken to be a string (character pointer) and characters from the string are printed until a null character or until the num- ber of characters indicated by the precision specification is reached; however if the precision is 0 or missing all characters up to a null are printed. u The unsigned integer arg is converted to decimal and printed (the result will be in the range 0 to 65535). % Print a `%'; no argument is converted. In no case does a non-existent or small field width cause truncation of a field; padding takes place only if the specified field width exceeds the actual width. Characters generated by printf are printed by putc(3). Examples To print a date and time in the form `Sunday, July 3, 10:02', where weekday and month are pointers to null-terminated strings: printf("%s, %s %d, %02d:%02d", weekday, month, day, hour, min); To print pi to 5 decimals: printf("pi = %.5f", 4*atan(1.0)); SEE ALSO
putc(3), scanf(3), ecvt(3) BUGS
Very wide fields (>128 characters) fail. PRINTF(3S)
All times are GMT -4. The time now is 04:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy