Search code examples
bashgrepconfiguration-filespipehead

line of bash code from .configure file


I need to understand the following line of code:

BIN_DIR=`grep BIN_DIR= $SMLCM | head -1`

where $SMLCH contains a path

This is what I understood so far:

  • grep will produce some string(s), possible paths. What does grep do with BIN_DIR=?

  • the pathes are passed to head and all files within the paths will be used to extract their first line

  • something is evaluated (what exactly?) and stored in BIN_DIR

Best regards,

Simon


Solution

  • This will find all occureneces of the literal string "BIN_DIR=" in the file specified in the $SMLCM variable and only take the first line of that output and assign it to BIN_DIR.

    Note that this may not work the way you want it to since whats gets assiggned to BIN_DIR is some string like "BIN_DIR=blah" that is it may have the same effect as the following:

    BIN_DIR="BIN_DIR=blah"