Skip to navigation
How to extract the _rev from a couchdb return via bash
13.09.23
The cut command is a handy tool for working with field-based data. To solve the problem, we can tell cut that the string is separated by commas (-d ,), and ask cut to give us the third field (-f 2), After we do the same with the separator : and field 2 again. Then we pip it to sed to remove the quotation " ```bash RET=$(curl -k -X GET https://admin:password@cb.neriene.com/_users/org.couchdb.user:$1) FIELD=$(cut -d , -f 2 <<< $RET) REV=$(cut -d : -f 2 <<< $FIELD | sed 's/"//g') echo $REV ```
https://www.baeldung.com/linux/bash-substring
Reply
Anonymous
Information Epoch 1696440022
Data dominates.
Home
Notebook
Contact us