BASH: pretty $PATH

 

  1. echo $PATH | tr : \\n

     

  2. echo $PATH | sed '#:#\n#g'

     

  3. echo $PATH | awk 'BEGIN{RS=":"}{print}'

     

  4. echo $PATH | awk '{gsub(/:/,"\n");print}'

     

  5. IFS=: read -ra entries <<< "$PATH"
    for entry in "${entries[@]}"; do
        echo $entry
    done

     

posted @ 2024-01-29 17:49  ascertain  阅读(1)  评论(0编辑  收藏  举报