Is there a way to view/show/print the source code of bash script with its includes (aka sources)? For example:sub.sh file     function showMe(){     echo INCLUDE    }main.sh file#!/bin/bash    source sub.shshowMe    echo OKThe print of main.sh will show:#!/bin/bash    showMe(){ echo INCLUDE}showMe    echo OK
Print source code of bash script with its includes
bash
You can try following awk:awk '/^source/ { while (getline l <$2 > 0) print l; close($2); next; } { print; }' main.shso each line which starts with source fname should be replaced with contents of file if exists.