[BASH] read 'line' issue with leading tabs and virtual line breaks
Heyas
I'm trying to read/display a file its content and put borders around it (tui-cat / tui-cat -t(ypwriter).
The typewriter-part is a 'bonus' but still has its own flaws, but thats for later.
So in some way, i'm trying to rewrite cat using bash and other commands.
But sadly it fails on leading tabs/spaces and virtual line breaks. [BASH] Getting a semi-tailing backslash when passing (escaped) variables to script , didnt help much, and the other 2 found threads regarding 'tailing backslash' as search criteria are also by me and not helping on this subject.
The file i'm displaying is the stats.sh scripts (see: [FUN] Get some stats of your project/s)
The code above encapsules the script just fine, with the && \ in the lines-section as a single string properly split (by tui-printf [-E]) onto 2 lines (originaly 4 lines ending with && \).
I'm trying to 'say': File-to-Display-snippet: Displays as: Expected:
tui-printf just prints what is passed (and escaped properly), and puts borders around it.
It does a string splitting, as the single string (all the && \ lines are read as ONE line) doesnt match a single output line .
Basicly i need a way to handle the commented out 'Simple Conditions' section (or those - what i call - virtual linebreaks).
Replacing tui-printf -E with echo, results in a faster display, which lacks the same flaws/issues.
I asume i've used the wrong search criteria/text?
And advice / ideas please?
Thank you
---------- Post updated 08-05-15 at 10:49 ---------- Previous update was 07-05-15 at 11:47 ----------
OK, guess i didnt minimize the code enough.
On the way, figured about the thingsi call virutal linebreaks, the read its -r option solved it.
Sample Text:
Sample Code:
Output - Is:
Output - Expected:
But me still stuck with leading tabs not beeing:
1) Converted to spaces (not required, i thought i'd had more luck to preserve/handle space chars rather than real tabs)
2) Displayed at all
Any advices please?
---------- Post updated at 11:10 ---------- Previous update was at 10:49 ----------
True, inside the script.
As far i can tell, there is no lasting effect for outside the script:
Seems right'ish to me.
EDIT:
I used a single IFS="" for both modes, cat and typewriter (the example above, -d 0.001 is the delay with each char (text only, not borders) is shown.
But changing anyway, for better practice, thank you for pointing out.
All- We have a performance issue in reading a file line by line. Please find attached scripts for the same. Currently it is taking some 45 min to parse "512444" lines.
Could you please have a look at it and provide any suggestions to improve the performance.
Thanks,
Balu
... (12 Replies)
Hi All- we have performance issue in unix to read line by line.
I am looking at processing all the records.
description: Our script will read data from a flat file, it will pickup first four character and based on the value it will set up variables accordingly and appended the final output to... (11 Replies)
Hello,
I'm works on Ubuntu server
My goal : I would like to read file line per line, but i want to started at the end of file.
Currently, I use instructions :
while read line;
do
COMMAND
done < /var/log/apache2/access.log
But, the first line, i don't want this. The file is long... (5 Replies)
Heyas
With my forum search term 'issue with leading dash' i found 2 closed threads which sadly didnt help me.
Also me was to eager to add the script, that i didnt properly test, and just now figured this issue.
So i have this code:
if ]
then while read line
do line="${line/-/'\-'}"... (7 Replies)
Hi All,
Am trying to write wrapper shell/bash script on a utility tool for which i need to pass 2 files as arugment to execute utility tool.
Wraper script am trying is to do with above metion 2 files.
utility tool accepts :
a. userinfo file : which contains username
b. item file : which... (2 Replies)
Hi All,
Need an urgent solution to an issue . We have created a ksh file or shell script which generates 1 DAT file. the DAT file contains extract of a select statement .
Now the issue is , when we are executing the ksh file , the output is coimng with page breaks and line breaks .
We have... (4 Replies)
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)
Hi! I have been struggling with a large file that has stray end of line characters.
I am working on a Mac (Lion). I mention this only because I have been mucking around with fixing my problem using sed, and I have learned far more than I wanted to know about Unix and Mac eol characters.
I... (1 Reply)
Hi All,
I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
I am using the while-loop to read a file.
The file has lines with null-terminated strings (words, actually.)
What I have by that reading - just a first word up to '\0'!
I need to have whole string up to 'new line' - (LF, 10#10, 16#A)
What I am doing wrong?
#make file 'grb' with... (6 Replies)