Sponsored Content
Full Discussion: awk prints only last line
Top Forums Shell Programming and Scripting awk prints only last line Post 302969639 by SkySmart on Thursday 24th of March 2016 11:53:20 PM
Old 03-25-2016
awk prints only last line

data.txt:

Code:
NEWTEXTS="frq=63,std=-0.00533584,time=Mar-21-(09:15:03)-2016,epoch=1458576903,avg=64.2059,212.698
frq=197,std=0.587585,time=Mar-21-(09:16:02)-2016,epoch=1458576962,avg=64.2059,483.756
frq=178,std=0.503514,time=Mar-21-(09:46:02)-2016,epoch=1458578762,avg=64.2059,500
frq=0,std=-0.284097,time=Mar-21-(10:12:01)-2016,epoch=1458580321,avg=64.2059,246
frq=145,std=0.357496,time=Mar-21-(10:13:01)-2016,epoch=1458580381,avg=64.2059,514.483
frq=178,std=0.503514,time=Mar-21-(10:16:01)-2016,epoch=1458580561,avg=64.2059,510.112
frq=84,std=0.0875845,time=Mar-21-(10:46:02)-2016,epoch=1458582362,avg=64.2059,1098.81
frq=63,std=-0.00533584,time=Mar-21-(10:55:02)-2016,epoch=1458582902,avg=64.2059,1192.06
frq=180,std=0.512363,time=Mar-21-(11:15:02)-2016,epoch=1458584102,avg=64.2059,528.333
frq=63,std=-0.00533584,time=Mar-21-(11:34:03)-2016,epoch=1458585243,avg=64.2059,422.222
frq=329,std=1.17166,time=Mar-21-(11:35:10)-2016,epoch=1458585310,avg=64.2059,237.082
frq=63,std=-0.00533584,time=Mar-21-(11:45:03)-2016,epoch=1458585903,avg=64.2059,252.381
frq=222,std=0.698204,time=Mar-21-(11:46:01)-2016,epoch=1458585961,avg=64.2059,470.721
frq=3,std=-0.270823,time=Mar-21-(12:11:01)-2016,epoch=1458587461,avg=64.2059,4800
frq=147,std=0.366346,time=Mar-21-(12:12:01)-2016,epoch=1458587521,avg=64.2059,586.395
frq=182,std=0.521213,time=Mar-21-(12:16:01)-2016,epoch=1458587761,avg=64.2059,491.209
frq=179,std=0.507938,time=Mar-21-(12:31:02)-2016,epoch=1458588662,avg=64.2059,565.363"

awk code:

Code:
echo "${NEWTEXTS}" | awk -F, '{a=$1; b=$2; c=$3; d=$4; e=$5; f=$6 } END{printf("%s,%s,%s,%s,%s,%0.f\n", a,b,c,d,e,f)}'

this awk code only prints the last line. but i want it to print all the lines but with the last field of each line rounded up.

any ideas?
 

10 More Discussions You Might Find Interesting

1. Solaris

Screen prints on SunOS 5.7

Is there an easy way to print what is on the screen? Running SunOS 5.7 and blackbox. (1 Reply)
Discussion started by: grayson
1 Replies

2. Shell Programming and Scripting

awk / grep / Prints all columns except the first one

I have the a file with the following data. File Content. 1249 snf06.3.0 sw version 1.1 code MD5 192F MD4 MD3 1248 sns06.3.0 sw version 1.1 code MD5 192F MD12 1250 sns06.3.0 sw version 1.1 code MD5 192F0\ MD8 1241 sns06.3.0 sw code MD5 19 1243 sn06.3.0 sw version 1.1 code MD5 19 12... (17 Replies)
Discussion started by: knijjar
17 Replies

3. Programming

Core image showing no prints

Hi All, I am facing a very peculiar problem with my applciation. The problem is that one of my process is making core very rarely.But when I am going to debug it,it is not showing any prints. The Make file is : g++ -g $(commonobjfiles) -o ipcl $(INCLUDES) -z muldefs -lpthread -lsocket... (0 Replies)
Discussion started by: unisuraj
0 Replies

4. Solaris

Epson ESC/P2 on solaris prints LD

I am hoping someone can help me with this little riddle. I have an oldish Epson ESC/P2 which I connected to a solaris10 box, with 2 queues, 1 with the solaris print filter so I can print from Solaris (works fine), and a second raw queue so that windows machines can print to it. The raw queue... (0 Replies)
Discussion started by: gdommett
0 Replies

5. Shell Programming and Scripting

awk system() prints extra 0 -- why?

Here's the command I'm running: # echo "hi" | awk '{etime = system("hostname") ; close("hostname") ; print etime""}' And here's the ouput: server.domain.tld 0 Why in the world is that second line, the one that's just "0", there? Many thanks in advance. (2 Replies)
Discussion started by: treesloth
2 Replies

6. Red Hat

hostname command prints nothing a null value

Hi , On my box everything works fine. But whenever I run command It returns nothing as you see @(none) too. Its very strange issue I have never noticed on any other system yet. Any one have any idea about this. Thank you (2 Replies)
Discussion started by: pratapsingh
2 Replies

7. Shell Programming and Scripting

prints some fields from different files into a line of new file

i have 3 files as below: i want to print 1st,2nd,5th and 10th filed of 1st to 5th lines from each files into a line of an output file, so the result would be: : {line1}(field 1 of line 1 from file 1)(field 2 of line 1 from file 1)(field 5 of line 1 from file 1)(field 10 of line 1 from file... (1 Reply)
Discussion started by: saeed.soltani
1 Replies

8. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

9. Shell Programming and Scripting

awk prints unwanted new lines

Hello, I need a little help with the following: I'm using AWK to read input from a comma-seperated value file, and only printing certain fields like so: awk -F "," '{print $1,$3,$6}' /list.csv | tail -1 Which outputs the following: server1 APPID OS I run into a problem... (8 Replies)
Discussion started by: LinuxRacr
8 Replies

10. Shell Programming and Scripting

Awk: BEGIN: prints nothing

My code fails to do anything if I've BEGIN block in it: Run the awk script as: awk -f ~/bin/sum_dupli_gene.awk make_gene_probe.txt #!/usr/bin/awk -f BEGIN { print ARGV #--loads of stuff } END{ #more stuff } (14 Replies)
Discussion started by: genome
14 Replies
GETDATE(1)                                                         User Commands                                                        GETDATE(1)

NAME
getdate - AME SYNOPSIS
[-dv][-n dec][-f format] [ra dec sys] itype2otype [date and/or time] DESCRIPTION
Convert date and time between various formats [-dv][-n dec][-f format] itype2otype @file itype: nfd=ISOFITS fd=FITS, dt=yyyy.mmdd, hr=hh:mm:ss, deg=dd:mm:ss jd=Julian Date, mjd=Modified Julian Date hjd=Heliocentric Julian Date, mhjd=Modified HJD ep=epoch, epj=Julian epoch, epb=Besselian epoch lt=local time, ut=UT, ts=seconds since 1950-01-01 now=current time, ang=fractional degrees otype: fd=FITS, dt=yyyy.mmdd, jd=Julian Date, mjd=Modified Julian Date hjd=Heliocentric Julian Date, mhjd=Modified HJD hr=hh:mm:ss, deg=dd:mm:ss, ang=fractional degrees ep=epoch, epj=Julian epoch, epb=Besselian epoch ts=seconds since 1950-01-01, tsu=Unix sec, tsi=IRAF sec gst=Greenwich Sidereal Time, lst=Local Sidereal Time @file: First one or two columns are in itype format ra dec sys: Need for Heliocentric conversions -a: Append date to input file, if there is one -d: Print date without time -e: Print output as ET/TDT/TT converting from UT -f: Format for output number (C printf) -h hours: Longitude in hours, west positive -l degrees: Longitude in degrees, west positive -n: Number of decimal places in sec, epoch, JD -t: Print time without date -v: Verbose getdate 3.8.4 June 2012 GETDATE(1)
All times are GMT -4. The time now is 08:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy