Sponsored Content
Top Forums Shell Programming and Scripting Merge lines in a file with Awk - incorrect output Post 302338138 by mv652 on Monday 27th of July 2009 06:30:12 AM
Old 07-27-2009
Hi just in case anyone reads this thread wants to know if it was solved.

I eventually realised the lines were, in fact, been truncated correctly. When 'cat <output-file>', I had the output below:

Code:
,     0 output errors, 0 collisions, 0 interface resetsred
,     0 output errors, 0 collisions, 0 interface resetsred down
,     0 output errors, 0 collisions, 150 interface resetsd, 3 abort
,     0 output errors, 0 collisions, 150 interface resetsored, 9 abort

But, when going into the file with vi, for example, I had:

Code:
FastEthernet0/0 is up, line protocol is up ^M,     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored^M,     0 output errors, 0 collisions, 0 interface resets
FastEthernet0/1 is administratively down, line protocol is down ^M,     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored^M,     0 output errors, 0 collisions, 0 interface resets
Serial1/0:0 is up, line protocol is up ^M,     8 input errors, 0 CRC, 8 frame, 0 overrun, 0 ignored, 3 abort^M,     0 output errors, 0 collisions, 150 interface resets
Serial1/0:12 is up, line protocol is up ^M,     26 input errors, 10 CRC, 16 frame, 0 overrun, 0 ignored, 9 abort^M,     0 output errors, 0 collisions, 150 interface resets

So the syntax
Code:
awk 'ORS=NR%3?",":"\n"' FILE

was correct, it was just not displaying correctly on terminal.


Cheers
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK Merge Fields for Print Output

I've got a file with each record on a separate line and each record contains 34 fields separated by a colon and i'm trying to re-arrange the order of the fields and merge together certain fields separated by a slash (like field7/field28). I tried using an awk print statement like awk -F: 'BEGIN... (5 Replies)
Discussion started by: RacerX
5 Replies

2. Shell Programming and Scripting

awk : deleting specific incorrect lines

Hello friends, I searched in forums for similar threads but what I want is to have a single awk code to perform followings; I have a big log file going like this; ... 7450494 1724465 -47 003A98B710C0 7450492 1724461 -69 003A98B710C0 7450488 1724459 001DA1915B70 trafo_14:3 7450482... (5 Replies)
Discussion started by: enes71
5 Replies

3. Shell Programming and Scripting

Awk: How to merge duplicate lines and print in a single

The input file: >cat module1 200611051053 95 200523457498 35 200617890187 57 200726098123 66 200645676712 71 200744556590 68 >cat module2 200645676712 ... (10 Replies)
Discussion started by: winter9
10 Replies

4. Shell Programming and Scripting

awk file comparison, x lines after matching as output

Hello, I couldn't find anything on the Forum that would help me to solve this problem. Could any body help me process below data using awk? I have got two files: file1: Worker1: Thomas Position: Manager Department: Sales Salary: $5,000 Worker2: Jason Position: ... (5 Replies)
Discussion started by: killerbee
5 Replies

5. Shell Programming and Scripting

Merge multiple lines in same file with common key using awk

I've been a Unix admin for nearly 30 years and never learned AWK. I've seen several similar posts here, but haven't been able to adapt the answers to my situation. AWK is so damn cryptic! ;) I have a single file with ~900 lines (CSV list). Each line starts with an ID, but with different stuff... (6 Replies)
Discussion started by: protosd
6 Replies

6. Shell Programming and Scripting

Find duplicates in column 1 and merge their lines (awk?)

Hi, I have a file (sorted by sort) with 8 tab delimited columns. The first column contains duplicated fields and I need to merge all these identical lines. My input file: comp100002 aaa bbb ccc ddd eee fff ggg comp100003 aba aba aba aba aba aba aba comp100003 fff fff fff fff fff fff fff... (5 Replies)
Discussion started by: falcox
5 Replies

7. UNIX for Dummies Questions & Answers

ID incorrect field values in dat file and output to new file

Hi All I have a .dat file, the values are seperated by ". I wish to identify all field values in field 14 that are not '01-APR-2013' band then copy those records to a new file. Can anyone suggest the UNIX command required. Thanks in advance Andy (2 Replies)
Discussion started by: aurum1313
2 Replies

8. Shell Programming and Scripting

Df -h | awk - output incorrect matching

Running solaris 9, on issuing the follwing command df -h | awk '$5 > 45 {print}' Filesystems with utilisation > 45% are being displayed as well as those between 5 and-9%!!! (3 Replies)
Discussion started by: squrcles
3 Replies

9. Shell Programming and Scripting

E-mail Output Merge Lines for Some Text..

Hi all. This is the content of the text file used for the e-mail: TM ICP-EDW BILLING REGISTER USAGE BREAKDOWN_01062014.csv TM_ICP_EDWH_FICL_13062014.TXT TM_ICP_EDWH_FICL_16062014.TXT TM_ICP_EDW_Detailed Payment Journal Report_13062014.txt TM_ICP_EDW_Detailed Payment Journal... (9 Replies)
Discussion started by: aimy
9 Replies

10. Shell Programming and Scripting

awk to add lines with symbol to output file

In the awk below which does execute I get output that is close, except for all the lines that start with a # are removed. Some lines have one others two or three and after the script adds the ID= to the fields below the pattern in the awk, I can not seem to add the # lines back to the output. ... (5 Replies)
Discussion started by: cmccabe
5 Replies
syncstat(1M)						  System Administration Commands					      syncstat(1M)

NAME
syncstat - report driver statistics from a synchronous serial link SYNOPSIS
/usr/sbin/syncstat [-c] device [interval] DESCRIPTION
The syncstat command reports the event statistics maintained by a synchronous serial device driver. The report may be a single snapshot of the accumulated totals, or a series of samples showing incremental changes. Prior to these it prints the device name being used to query a particular device driver, along with a number indicating the channel number (ppa) under control of that driver. Event statistics are maintained by a driver for each physical channel that it supports. They are initialized to zero at the time the driver module is loaded into the system, which may be either at boot time or when one of the driver's entry points is first called. The device argument is the name of the serial device as it appears in the /dev directory. For example, zsh0 specifies the first on-board serial device. The following is a breakdown of syncstat output: speed The line speed the device has been set to operate at. It is the user's responsibility to make this value correspond to the modem clocking speed when clocking is provided by the modem. ipkts The total number of input packets. opkts The total number of output packets. undrun The number of transmitter underrun errors. ovrrun The number of receiver overrun errors. abort The number of aborted received frames. crc The number of received frames with CRC errors. isize The average size (in bytes) of input pack- ets. osize The average size (in bytes) of output pack- ets. OPTIONS
-c Clear the accumulated statistics for the device specified. This may be useful when it is not desirable to unload a particu- lar driver, or when the driver is not capable of being unloaded. interval syncstat samples the statistics every interval seconds and reports incremental changes. The output reports line utiliza- tion for input and output in place of average packet sizes. These are the relationships between bytes transferred and the baud rate, expressed as percentages. The loop repeats indefinitely, with a column heading printed every twenty lines for convenience. EXAMPLES
Example 1: Sample output from the syncstat command: example# syncstat zsh0 speed ipkts opkts undrun ovrrun abort crc isize osize 9600 15716 17121 0 0 1 3 98 89 example# syncstat -c zsh0 speed ipkts opkts undrun ovrrun abort crc isize osize 9600 0 0 0 0 0 0 0 0 In the following sample output a new line of output is generated every five seconds: example# syncstat zsh0 5 ipkts opkts undrun ovrrun abort crc iutil outil 12 10 0 0 0 0 5% 4% 22 60 0 0 0 0 3% 90% 36 14 0 0 0 1 51% 2% ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
syncinit(1M), syncloop(1M), attributes(5), zsh(7D) DIAGNOSTICS
bad interval: arg The argument arg is expected to be an interval and could not be understood. device missing minor device number The name device does not end in a decimal number that can be used as a minor device number. baud rate not set The interval option is being used and the baud rate on the device is zero. This would cause a divide-by-zero error when computing the line utilization statistics. WARNINGS
Underrun, overrun, frame-abort, and CRC errors have a variety of causes. Communication protocols are typically able to handle such errors and initiate recovery of the transmission in which the error occurred. Small numbers of such errors are not a significant problem for most protocols. However, because the overhead involved in recovering from a link error can be much greater than that of normal operation, high error rates can greatly degrade overall link throughput. High error rates are often caused by problems in the link hardware, such as cables, connectors, interface electronics or telephone lines. They may also be related to excessive load on the link or the supporting sys- tem. The percentages for input and output line utilization reported when using the interval option may occasionally be reported as slightly greater than 100% because of inexact sampling times and differences in the accuracy between the system clock and the modem clock. If the percentage of use greatly exceeds 100%, or never exceeds 50%, then the baud rate set for the device probably does not reflect the speed of the modem. SunOS 5.10 9 Mar 1993 syncstat(1M)
All times are GMT -4. The time now is 09:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy