Replacing line number w/spaces in DSDT compiler log
Hi, all,
I'm from the 8-bit micro days (Z-80, 6809, 6502, etc.) and used to program in assembly and machine code. But, that was 25 years ago and life happened. Now, I'm scripting for the hackintosh community and love every bit of it.
I'm parsing a DSDT compiler log for error/warning/remarks checking and would like to be able to replace the line number with spaces, because I need to retain the spacing. The positioning of the text is critical, as it points to the errors, as you'll see in the following example. The line number follows the dsdt_fixed.txt path. See the following random examples:
I'm removing the line number so I can do comparisons after DSDT editing. The editing may add/remove lines, so the line number will be pointing to different locations. I have all this figured out, but just think there's got to be a simpler way to accomplish this task.
A simple sed 's/[0-9]/ /g' won't work, as I may have digits in the rest of the line. Is there a way to limit the search/replace to just that line number or area of text, ignoring the rest of the DSDT code that follows on that line?
Here's the details:
"Debug/dsdt_fixed.txt" is a predictable string.
Line number appears to be in a fixed, flush right location, with padded spaces at left. (The compiler may determine the maximum number of lines in the code and set the number of spaces in advance.)
I was doing this in bash by breaking up the line, which works fairly well, but was relatively slow.
Then, I thought of this idea. It works fast fine, but seems amateurish: EDIT: Okay, I need to change the order of the commands so that sed replaces the largest number first and works on down. Whoops.
THIRD EDIT <sigh>: Okay, I had to add the padding in front of the numbering, as well as the [0-9] regex, instead of "." Works correctly, now.
Surely, there's a better idea, right? Nothing wrong with it, except it just seems verbose. However, I'm sticking with the code, until I get a better solution.
best of wishes,
MAJ
---------- Post updated at 07:02 PM ---------- Previous update was at 06:04 PM ----------
While I'm still talking to myself , it seems the extended regex works, too.
Thanks for letting me think out loud. I was working on this off and on for the past two days. Nothing like stalling on something seemingly "simple." Going to bed, then thinking, "Oh, I got it!" Get up and find out, nope, that doesn't work. Go back to bed. Rinse, lather, repeat.
MAJ
EDIT: Sorry to litter this place up. But, I think was making things a bit more complicated that necessary. Once I determine the number of spaces set by the compiler, it's a simple line of code:
Last edited by digital_dreamer; 08-11-2010 at 09:18 PM..
Reason: More edits, refreshed thinking about issue!
Hi I want to read a text file and replace various number of spaces between each string in to a single "," or any other character .Please let me know the command to do so. My input file is a txt file which is the output of a SQL table extract so it contains so many spaces between each column of the... (2 Replies)
Hello,
I have a file with hundreds of lines. Now I need to replace positions 750-766 in each line (whatever there is there) with spaces... how can I do that?
Which command to use?
The result will be all the lines in the file will have spaces in positions 750-766.
Thanks! (3 Replies)
Hi;
In following code
find LOG_DIR -type f | while read filename; do echo $filename; done
I want to precede each white space encountered in filename with \ so that when i use $filename for running some commands in do...done,it wont give me an error.
will appreciate ur help in this.... (1 Reply)
I want my program to replace tabs with spaces.1tab=4spaces.When i write aa(tab)aaa(tab)(tab)a(tab) it must show me aaxxaaaxxxxxaxxx. I think that my program works corectly but when a write aaa(tab)a it must show aaaxa but it is aaaxxxxxa.Please for help!!! That is my code:
#include <stdio.h>
... (3 Replies)
Hi Experts,
We are facing some while loading the "csv" file to target table.Some of the records are having values as :
Account number,Name,Address
"123","XYZ","302 Street,Washington,US"
"456","PQR"," 3233 Some Street,
Washington,US"
In the above file instead reading only two records it... (11 Replies)
Hi,
I have a file origFile.txt with values:
origFile.txt
.00~ 145416.02~ xyz~ ram kishor ~? ~ ~783.9
.35~ 765.76~ anh reid~ kelly woodburg ~nancy ~ ~?
Now each row in the file has value for 7 columns with "~" as delimiter.
The requirement was
i)I need to erase the blank spaces between... (2 Replies)
Hi,
I have a problem where I need to append few spaces(say 10 spaces) for each line in a file whose length is say(100 chars) and others leave as it is.
I tried to find the length of each line and then if the length is say 100 chars then tried to write those lines into another file and use a sed... (17 Replies)
Hi,
i have a tab dilimeted file.The records are :header is having column names.I am facing the following issue :
I want to convert the spaces only for header file into "_" in the unix shell but the problem is that if i use sed command all the blank spaces are getting replaced by "_".
For... (3 Replies)
hi all
this is the part i am facing a problem
eg data: filename : tr1
+ T 40
this is a sample record in that file ... the value of T can be anything, but will be a single character.
i need to cut from field two, and i am using this command
cut -d " " -f2 tr1 >tr3
and the o/p is ... (7 Replies)
hi,
I have some 50 C files in which for indentation of code some devlopers used tabs, but we dont want any tab used for indentation.
I have following 2 need.
1) find tabs from all 50 files (which are in one directory )
2) replace them with 4 spaces.
Thanks
Rishi (6 Replies)