So in this lecture we would like to display file content with space and top issues in that background
color.
So in order to display file content we need to read line by line.
So just after fixing our bright command display graphically space errors so we exactly know what we
are doing.
Firstly we need to be sure that user specified files which exist as we want to read line by line from
that file.
So use Desch f overarm for checking if variable file represents regular file.
Now if we are sure that we have a regular file that read line by line from that file but in order to
read line with space and top issue use instead of violating line.
So instead of that you need to use while internal field separator segfaults to read them at a line.
This ensures us that inherit lines will be all spaces and taps without any change.
Otherwise we will only violate the line we vote on secretly spaces and thus at the beginning or at the
end of lines.
And of course we are getting clients from variable file which represents files specified by user.
So now we need to think what we will do if line will have some space or top issue.
We need to show that space and that part inherit background.
Otherwise if line has no space or that we should just print this line.
So now we can do that by printing whole line if there is no space visual You can write a comment about
that also.
So if there is no space issue on line just print the line
for checking if there is space or top issue at the beginning or the end of the line we will use SET
command.
Q
So if we find space or top which is represented by character class blahing.
So if we find space or top issue
at the end of a line
and or line is presented by the sign Viva exist with exit status for example 9 and if there is space
or issue a deep beginning of that line.
We will exit.
For example read exit's that was 7.
And as we don't want to print now anything to the screen we need to direct output from set command to
Dev-Null.
So just to recap if we find at least one space or two up this is the reason why we are using in a regular
expression bus symbol.
So if we find spaces or taps a deep end of lines we are exiting with exits.
That was 9.
And if you find spaces or tabs at the beginning of a line we will exit exits that was seven.
Now we can ask if exit status is zero.
That means if no error was spotted in this line so even though error was spotted in diesel line we can
just print the line to the screen
so I echo the lower side line and then we can use keyboard continuing to continue Kieve or does it finish
actually low and continue with another one.
So in our case it would jump to the next line in a while loop.
We can of course use for example statement if we don't want to use continue command.
And in that statement we will specify part of code for case exit status is not zero.
So that means for days when in the line was spotted some spaces are a top issue.
But I will go in this case of it continue command.
So we basically wrote code for reading each line and for each line we are checking if there is space
or a tab issue.
At the beginning or at the end of line if there is no issue for a specific line we are printing this
line.
So now let's test it.
From our script and specify some file location
and I can see it printed all the lines without space issue.
Good.
Now open our test file and make space.
Our top issue on multiple lines.
For example I have some space issues in the first line and also in the search line.
When running our script again I cannot see first and line as those lines contain space or type issue.
This is working perfectly.