I would like to print my output of the ls command as a JSON array with the current working directory as the prefix for every element in the array.
I managed to find another thread which helped me sort the first part out of my problem, but would appreciate some help with the prefix part.
Lets say I have the following directory and file structure:
Docs (Directory)
|
+-- Random file 1
|
+-- Readme (Working Directory)
| |
| +-- Readme.md
| +-- Readyou.md
When I execute the following command in the Readme Directory (taken from the thread I linked to earlier):
python -c 'import os, json; print json.dumps(os.listdir("."))'
I get the following output:
["Readme.md", "Readyou.md"]
What I would like to achieve is the structure above, BUT with the working directory as the prefix for every element in the array.
["Readme/Readme.md", "Readme/Readyou.md"]
Is this something that can managed pretty straightforward in bash?