Shell command variable method to remove spaces

Shell variable removal method

**Hereby solemnly declare! This article is an original work, and it is not easy for the editor to write it. Help me like it and follow it~ Reprint friends, please indicate the source! Thanks**

    1. Remove left and right spaces

    > temp=’ x  y, oio213   ’
    > echo  $(echo $temp)
    > 结果:x  y, oio213
    

    2. Remove all spaces

    > temp=’ x  y, oio213   ’
    > echo  ${temp// /}
    > 结果:xy,oio213
    

    3. Remove all spaces [awk]

    > temp=’ x  y, oio213   ’
    > echo "$temp" | awk '{gsub(/ /,"")}1'
    > 结果:xy,oio213
    

    Guess you like

    Origin blog.csdn.net/jjc120074203/article/details/126663391