I would suggest awk as a reformatter. There are many different approaches to identifying and isolating the various pieces of a line. In the following, awk uses the "=>" and the colon that occurs beyond that to identify segments of the line, then prints the line with an exact format.
Those widths on the print command are minimum column widths. If a line segment comes in that exceeds those minimums, the longer segments will be accommodated, thus pushing the columns out of alignment for that one line. We could easily truncate instead, but we don't want that. I kept the overall width to fit in 80 columns, but an output line can be up to about 2400 characters.
I did not do the dot-fill at this time. I did not check for bad data. If a line is missing the "=>" for example, the entire line would be seen as segment 1.
here is a right copy of my original line :
src**>...hwi_adc.....=>...Line...332:..../*..comments.....*/
cin**>...hwi_resource_manager.....=>...Line...33333:..../*..comments.....*/
(of course don't take care of ......)
And my goal is to get:
src**>...hwi_adc........................=>...Line...332......./*..comments.....*/
cin**>...hwi_resource_manager.....=>...Line...33333..../*..comments.....*/
Hmmm ...
I'm going to guess, for now, that your awk does not like making changes to the current buffer line, either entire line ($0) or even individual fields on the line like $1. Bummer, because I use that a lot on HP-UX. What is your platform?
OK, following is a solution that does not modify the buffer. It first identifies where in the line the => and the first /* are. It then generates pad1 and pad2 to be the required # dots to force the => to col 35 and the /* to col 57 (35+22). If an input line is already beyond these, nothing will get truncated, pad1 and pad2 will just be null for these.
Some platforms do not handle the quoted awk program spanning multiple lines, but I don't think you have that issue. If so, we can put line continuations and semicolons, or just bring in the awk code with the -f option.
Hi Jimbo,
sorry for the delay but I'm just back from vacation....some fresh air will help to think....
My platform is Sun Solaris OS 5.5.1 on Ultra 5.
Your solution does not work fine. Columns are not aligned yet.
Here is a cut and paste of my screen:
cin**> sk_5457.h => Line 1270 /*--- approach, each i/o mapped on the TPU must use the specific TPU ---*/
cin**> filter.c => Line 36 /* Lag_Filter_Approx_W -h- */
cin**> filter.c => Line 272 CARDINAL Lag_Filter_Approx_W (register CARDINAL NewValue,
cin**> filter.c => Line 297 } /*** End of Lag_Filter_Approx_W ***/
cin**> filter.h => Line 35 /* Lag_Filter_Approx_W */
cin**> filter.h => Line 87 CARDINAL Lag_Filter_Approx_W (register CARDINAL NewValue,
cin**> filter.h => Line 104 /* - Create Lag_Filter_Approx_W function to round up to the next */
cin**> h_qadc64.c => Line 47 /*--- This logic is called from the appropriate 58X event ---*/
cin**> v_wdg.c => Line 623 /*** appropriate EEPROM or ETC received buffer. ***/
and here is what I would expect as a result :
cin **> sk_5457.h ...........=> Line 1270 .................:........../*--- approach, each i/o mapped on the TPU must use the specific TPU ---*/
cin **> filter.c ...................=> Line 36 .....................:........../* Lag_Filter_Approx_W -h- */
cin **> filter.c ...................=> Line 272 ...................:..........CARDINAL Lag_Filter_Approx_W (register CARDINAL NewValue,
cin **> filter.c ...................=> Line 297 ...................:..........} /*** End of Lag_Filter_Approx_W ***/
cin **> filter.h ...................=> Line 35 .....................:........../* Lag_Filter_Approx_W */
cin **> filter.h ...................=> Line 87 .....................:..........CARDINAL Lag_Filter_Approx_W (register CARDINAL NewValue,
cin **> filter.h ...................=> Line 104 ...................:........../* - Create Lag_Filter_Approx_W function to round up to the next */
cin **> h_qadc64.c ........=> Line 47 ......................:........../*--- This logic is called from the appropriate 58X event ---*/
cin **> v_wdg.c ...............=> Line 623 ...................:.........../*** appropriate EEPROM or ETC received buffer. ***/
Do you see a solution ?
I was using the following awk but I get a problem when a "=" is part of left side....and I get only one sort on first "=>".
In fact, the three missing columns to generate are :
at "=>" , at ":" and at start of last line (after the line number) which can be a comment or c code.
How do you concatenate a line with awk ? I was using something like :
hello
i am having a file having a matrix as the following
4.1 5.5 6.55
7.2 8.2 1.002
i am having around 1 lakh rows, now i need a program in which i show give min x and min y and min z values and as well as max x max y max z, the values between these minimun and maximum values should be... (1 Reply)
Hello,
I'm trying to figure out how to speed up the following as I want to use multiple commands to search thousands of files.
is there a way to speed things up?
Example I want to search a bunch of files for a specific line, if this line already exists do nothing, if it doesn't exist add it... (4 Replies)
Sed command to replace a line in a file using line number from the output of a pipe.
Is it possible to replace a whole line piped from someother command into a file at paritcular line...
here is some basic execution flow..
the line number is 412
lineNo=412
Now i have a line... (1 Reply)
Hi,
I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :-
./sample.sh: line... (12 Replies)
here is what i want to achieve.. i have a file with below contents
cat fileName
blah blah blah
.
.DROP this
REJECT that
.
--sport 7800 -j REJECT --reject-with icmp-port-unreachable
--dport 7800 -j REJECT --reject-with icmp-port-unreachable
.
.
.
more blah blah blah
--dport 3306... (14 Replies)
my requirement is,
consider a file output
cat output
blah sdjfhjkd jsdfhjksdh
sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf
hellow there
this doesnt look good
et cetc etc
etcetera
i want to replace a line of line number 4 ("this doesnt look good") with some other line
... (3 Replies)
I am trying to delete lines in archived Apache httpd logs
Each line has the pattern:
<ip-address> - - <date-time> <document-request-URL> <http-response> <size-of-req'd-doc> <referring-document-URL>
This pattern is shown in the example of 6 lines from the log in the code box below. These 6... (1 Reply)
Hi,
I have a text file similar to the example below and I want to print the second line every time after the "--------------------------" pattern is found. The pattern is a fixed length of - characters.
Example of input;
1 --------------------------
2
3 39184018234
4 ... (10 Replies)
I'm new to using sed and grep commands, but have found them extremely useful. However I am having a hard time figuring this one out:
Delete every line containing the word CEN and the next line as well.
ie. test.txt
blue
324 CEN
green
red
blue
324 CEN
green
red
blue
to produce:... (2 Replies)
Hi there,
may someone easily help me on this :
I want to insert a text in a specific line number like :
linenumb2start=`cat memory_map.dld | nl -ba | egrep -i "label" | cut -f1`
line2insert=`expr $linenumb2start + 2`
and now I need to replace something like {} with {comment} at... (8 Replies)