Search code examples
linuxshellgitlab-cigitlab-ci-runnercicd

how to create a readme.md file dynamically from the command output linux


am tying automate server commands through gitlab ci and create a readme file from that

right now I have a GitLab cicd pipeline which will get the list of installed installed software's in Linux server and store it in a file

yum list installed >> softwarelist.txt

but I want to create a readme file dynamically from the output of the above commands for example

readme file sample below

# installed software's

nodejs2.0.0  
java8

can anyone guide me to implement a way to archive it through gitlab pipeline or through shell script


Solution

  • Here is how it could be done as a shell script:

    #!/bin/bash
    # insert headline
    echo '# Installed software' > softwarelist.md
    
    # insert package list
    yum list installed >> softwarelist.md
    
    # insert markdown bulletpoints  
    sed -i '2,$ s/^/- /g' softwarelist.md
    

    This is what softwarelist.md will look like


    Installed software

    • nodejs2.0.0
    • java8
    • anotherpackage1.0