New answers tagged

0

Bash script # Get the last number (ID) last=$(awk -F':' '{print $1}' in.txt | tail -1) # Right align and print column $1 # Number of digits for the biggest number ( digits=${#last} ) awk -F':' -v digits=${#last} '{printf "%*s\n", digits, $1}' in.txt > out.txt # Get all columns except the first one cut -d':' -f 2- in.txt > out2.txt # We ...


1

Here you are: File: book.awk BEGIN { FS = ":" } { id = $1 $1 = "" sub(/^ +/, "", $0) printf("%3d: %s\n", id, $0) } Execution: recsel ... | recfmt ... | awk -f book.awk Output: 1: Book title 2: Book title 55: Book title 128: Book title


0

If you have an existing JSON document in file.json and you just want to insert the content into the correct place, using jq, jq --rawfile content test.txt '."test.txt".content |= $content' file.json If the content should be base64-encoded: base64 test.txt | jq --rawfile content /dev/stdin '."test.txt".content |= $content' file.json ...


1

I had to escape some JSON for inclusion in other JSON, and there's a really simple solution: $ jq @json <<< '{"Hello": "World"}' "{\"Hello\":\"World\"}"


Top 50 recent answers are included