Sponsored Content
Full Discussion: Formatted Output
Top Forums Shell Programming and Scripting Formatted Output Post 302194215 by era on Monday 12th of May 2008 12:59:17 PM
Old 05-12-2008
If the lines were much longer than an input block (512 bytes on some ancient machines; something around 2 to 8 kbytes on contemporary U*ces I'd guess) then taking care to not read the file line by line might make sense, but if the sample data is representative, reading the file line by line is probably the most efficient you can get. Anyway, the awk script above should hopefully work, perhaps with some minor modifications.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Formatted output in KSH

Hi, Is there some way to get formatted output in ksh? Something like a properly alligned tabular format. I tried adding '\t' to echo statements, but it doesn't come properly alligned 'hello' A simple Hello 'helloworld' A helloworld statement I need the second coloumn to... (1 Reply)
Discussion started by: psynaps3
1 Replies

2. Shell Programming and Scripting

formatted output with commas

var=12345 echo $var >>>12345 printf "%8.1f \n" $var >>> 12345.0 How to get this as 12,345? I suppose I could break into sections by dividing by 1000 or 1000000. But, is the a trick to this? (4 Replies)
Discussion started by: joeyg
4 Replies

3. Shell Programming and Scripting

Formatted output - awk

Hi I have the following records in a file SABN YOURTUBE 000514 7256 SACN XYOUDSDF 000514 7356 SADN KEHLHRSER 000514 7656 SAEN YOURTUBE 000514 7156 SAFN YOURTUBE 000514 7056 I need to put this in the format like this printf '%s %-50s %6s %-6s\n' I am not going to read individual... (3 Replies)
Discussion started by: dhanamurthy
3 Replies

4. Shell Programming and Scripting

cut - columns with formatted Output

Hi I have the input file as below ***TEST10067 00567GROSZ 099 00567CTCTSDS90 ***TEST20081 08233GROZWEWE 00782GWERW899 ***TEST30088 08233GROZWEWE 00782GWERW899 I am finding the lines starting with *** and outputing as below TEST10067 TEST20081 TEST30088 I need a space between TEST1... (9 Replies)
Discussion started by: dhanamurthy
9 Replies

5. Shell Programming and Scripting

Formatted output of shell script

Hello, I am working on one script which is giving output as a pipe "|" separated abcd | efgh | 20090745 abcdefgh | efg | 20090622 Can any one please help me i want it to be formatted as pipe will be aligned, or the output looks like a table. (2 Replies)
Discussion started by: vikash_k
2 Replies

6. Shell Programming and Scripting

output - tab formatted - awk

Dear All, Good Day. I would like to hear your suggestions for the following problem: I have a file with 5 columns with some numbers in 16 lines as shown below. Input file: Col 1 Col 2 Col 3 Col 4 Col 5 12 220 2 121 20 234 30 22 9... (3 Replies)
Discussion started by: Fredrick
3 Replies

7. UNIX for Dummies Questions & Answers

Request for Formatted Output

Can you please tell me how to just get only the output of dealers I & V information along with their subtotals in the next line of the file and create a new file, The dealer position along with corresponding totals may change everyday to any position above or below in the file, please help Thanks (2 Replies)
Discussion started by: Ariean
2 Replies

8. HP-UX

Formatted TOP command output in file

Hi All, I want generate HP-UX overall system performance report. I tried executing top command and write that out put to file. but am not able to view the report in proper format. I can see report like below in file but i can see properly in terminal. Please suggest how can i get... (2 Replies)
Discussion started by: lravip123
2 Replies

9. Programming

Formatted output in PERL

Hi Techies, I'm a newbie to PERL, Please help me with following problem. I have an input text file like below cat Input.txt 418673132,P 492538858,P 384535478,P 521522357,I 529435679,I 183617024,P 184414408,I 735510689,P 736238343,I 411642045,I 412690979,I 104232783,I (2 Replies)
Discussion started by: mahi_mayu069
2 Replies

10. Shell Programming and Scripting

Shell Script for formatted output

06/26/2017 23:40:40 CAUAJM_I_10082 06/26/2017 23:40:40 CAUAJM_I_40245 EVENT: CHANGE_STATUS STATUS: STARTING JOB: IOALPPRXXBD_ALPGLGENFAALL MACHINE: aspsun14 06/26/2017 23:40:42 CAUAJM_I_40245 EVENT: CHANGE_STATUS STATUS: RUNNING JOB:... (10 Replies)
Discussion started by: Sandeep Behera
10 Replies
IO::BufferedSelect(3pm) 				User Contributed Perl Documentation				   IO::BufferedSelect(3pm)

NAME
IO::BufferedSelect - Line-buffered select interface SYNOPSIS
use IO::BufferedSelect; my $bs = new BufferedSelect($fh1, $fh2); while(1) { my @ready = $bs->read_line(); foreach(@ready) { my ($fh, $line) = @$_; my $fh_name = ($fh == $fh1 ? "fh1" : "fh2"); print "$fh_name: $line"; } } DESCRIPTION
The "select" system call (and the "IO::Select" interface) allows us to process multiple streams simultaneously, blocking until one or more of them is ready for reading or writing. Unfortunately, this requires us to use "sysread" and "syswrite" rather than Perl's buffered I/O functions. In the case of reading, there are two issues with combining "select" with "readline": (1) "select" might block but the data we want is already in Perl's input buffer, ready to be slurped in by "readline"; and(2) "select" might indicate that data is available, but "readline" will block because there isn't a full $/-terminated line available. The purpose of this module is to implement a buffered version of the "select" interface that operates on lines, rather than characters. Given a set of filehandles, it will block until a full line is available on one or more of them. Note that this module is currently limited, in that(1) it only does "select" for readability, not writability or exceptions; and(2) it does not support arbitrary line separators ($/): lines must be delimited by newlines. CONSTRUCTOR
new ( HANDLES ) Create a "BufferedSelect" object for a set of filehandles. Note that because this class buffers input from these filehandles internally, you should only use the "BufferedSelect" object for reading from them (you shouldn't read from them directly or pass them to other BufferedSelect instances). METHODS
read_line read_line ($timeout) read_line ($timeout, @handles) Block until a line is available on one of the filehandles. If $timeout is "undef", it blocks indefinitely; otherwise, it returns after at most $timeout seconds. If @handles is specified, then only these filehandles will be considered; otherwise, it will use all filehandles passed to the constructor. Returns a list of pairs "[$fh, $line]", where $fh is a filehandle and $line is the line that was read (including the newline, ala "readline"). If the filehandle reached EOF, then $line will be undef. Note that "reached EOF" is to be interpreted in the buffered sense: if a filehandle is at EOF but there are newline-terminated lines in "BufferedSelect"'s buffer, "read_line" will continue to return lines until the buffer is empty. SEE ALSO
IO::Select AUTHOR
Antal Novak, <afn@cpan.org> COPYRIGHT AND LICENSE
Copyright (C) 2007 by Antal Novak This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. perl v5.10.1 2007-03-13 IO::BufferedSelect(3pm)
All times are GMT -4. The time now is 03:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy