Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 527

read raw input lines and output single array

$
0
0

I have a directory with files in it. I would like to create an array from that list of files. I thought it would be pretty easy, like:

ls mydir | jq -R '[.]'["file1"]["file2"]["file3"]

The only thing I could figure out is this:

ls mydir | jq -sR '[split("\n")[]|select(.|length>0)]'["file1","file2","file3"]

Is there a better way?


Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>