Create html file with bash script.

We will present a more special method of using the Linux command line.
This method comes in helping those who need to text or HTML content.
In fact, a combination of Linux commands to get an output.
Suppose we have a list of jpeg files in folder image.
They should exist into HTML to be displayed.
As we know an image has the form:

The list of the file is :

My method uses two commands: ll and awk.
First, I will display files:

I created one variable f1.
In these variables put the beginning of each line:

We add two sed commands.
First, remove the space before the file name.
The second will add the rest to complete the link.
The xargs command is used with echo and print the first part of the link.
Finally, we use <<< aaaa.html to output the HTML file.
And this is the final command:

This is all.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.