jq is useful to slice, filter, map and transform structured json data.
brew install jq
# ---------------------------------- | |
# Colors | |
# ---------------------------------- | |
NOCOLOR='\033[0m' | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
ORANGE='\033[0;33m' | |
BLUE='\033[0;34m' | |
PURPLE='\033[0;35m' | |
CYAN='\033[0;36m' |
db.getCollection('fs.chunks').aggregate([ | |
{ $lookup: { from: 'fs.files', localField: 'files_id', foreignField: '_id', as: 'file' } }, | |
{ $unwind: { path:'$file', preserveNullAndEmptyArrays: true } }, | |
{ $match: { file: { $exists: false } } }, | |
{ $project: { _id: 1, files_id: 1 } }, | |
]).forEach(function(chunk) { | |
printjson(chunk); | |
// db.getCollection('fs.chunks').remove({ _id: chunk._id }); | |
}); |
"Bash script header template": { | |
"prefix": "bashhead", | |
"body": [ | |
"#!/usr/bin/env bash", | |
"#", | |
"# Desc: ${1:description}", | |
"#", | |
"# Version: ${2:versionNumber}", | |
"#", | |
"# Usage: ${3:ScriptName} [${4:options}] ${5:args}", |