in CODING, Tips & Tricks

Another Thing I Keep Forgetting!

Every time I write a Bash script that loops through something, I test printing out the variable and it always splits the spaces across new lines so an app named ‘jHelper GUI’ ends up as:


The thing I keep forgetting to sort this is IFS! so I just need to do the following:

#!/usr/bin/env bash


# Loop through apps and print out basename
for app in /Applications/*; do
    echo "$(basename ${app})"
unset IFS