• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

Command Line Search "Tools"

dcsobral

New member
I search for stuff so often that I've now turned a number of common queries into little functions/aliases to use on command line. I do this on WSL, Windows' Linux subsystem, using BASH and with XMLStarlet installed. I put it on my ~/.bashrc so it loads up automatically.

They are all ignoring upper case/lower case. "Schematic" also searches for unlock by perks and skills.

Code:
alias loc='grep -i Localization.txt -e'
alias sel='xmlstarlet sel'

function schematic() {
    xmlstarlet sel -t -m / --var "l='abcdefghijklmnopqrstuvwxyz'" --var "u='ABCDEFGHIJKLMNOPQRSTUVWXYZ'" -m "//item/property/property[@name='Recipes_to_learn' and contains(translate(@value, \$u, \$l), translate('${1}', \$u, \$l))]" -o "Schematic " -v ../../@name -o ": " -v @value -n items.xml
    xmlstarlet sel -t -m / --var "l='abcdefghijklmnopqrstuvwxyz'" --var "u='ABCDEFGHIJKLMNOPQRSTUVWXYZ'" -m "//recipe[contains(translate(@name, \$u, \$l), translate('${1}', \$u, \$l))]" -v "name(..)" -o " " -v ../@name -o ": " -v @name -o " (" -v @unlock_level -o ")" -n progression.xml
}

function item() {
    xmlstarlet sel -t -m / --var "l='abcdefghijklmnopqrstuvwxyz'" --var "u='ABCDEFGHIJKLMNOPQRSTUVWXYZ'" -m "//item[contains(translate(@name,\$u,\$l),translate('${1}',\$u,\$l))]" -c . -n items.xml
}

function block() {
    xmlstarlet sel -t -m / --var "l='abcdefghijklmnopqrstuvwxyz'" --var "u='ABCDEFGHIJKLMNOPQRSTUVWXYZ'" -m "//block[contains(translate(@name,\$u,\$l),translate('${1}',\$u,\$l))]" -c . -n blocks.xml
}

function recipe() {
    xmlstarlet sel -t -m / --var "l='abcdefghijklmnopqrstuvwxyz'" --var "u='ABCDEFGHIJKLMNOPQRSTUVWXYZ'" -m "//recipe[contains(translate(@name,\$u,\$l),translate('${1}',\$u,\$l))]" -c . -n recipes.xml
}
 
Back
Top