#!/usr/bin/env bash IFS=$'\n' string=($(find . -maxdepth 1 -mindepth 1 -type d)) unset IFS for item in "${string[@]}"; do echo "|${item}|" done