Results 1 to 4 of 4

Thread: bash add space

  1. #1
    Join Date
    Jul 2012
    Beans
    688
    Distro
    Ubuntu 18.04 Bionic Beaver

    bash add space

    Hi
    I simply want to add space in a line with bash. For ex:
    echo $id $idd xp$c >> ./mass.txt
    should give something alike:
    Code:
    id               idd                                xp
    and not:
    id idd xp
    Thanks
    Last edited by MikeCyber; August 17th, 2017 at 03:25 PM.

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: bash add space

    The forum has "code tags" - Adv Reply (# button) - or in the Advanced Editor - or am I missing the question completely?
    Code:
    echo $id       $idd        xp$c          >>         ./mass.txt
    So I was completely missing the point.
    You can just quote everything.
    Code:
    echo "$id       $idd        xp$c        "  >>         ./mass.txt
    Last edited by TheFu; August 17th, 2017 at 03:56 PM. Reason: fixed.

  3. #3
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,588
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: bash add space

    Code:
    echo "$id       $idd        xp$c      "    >>         ./mass.txt
    or something like...
    Code:
    printf "%-10s, %7s %8s   \\n" "$id" "$idd" "xp$c" >>         ./mass.txt
    depending on how many spaces you want where and whether you want data left or right justified within a field. See 'info printf' for details.

  4. #4
    Join Date
    Jul 2012
    Beans
    688
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: bash add space

    Thanks. I'll try in the next days.
    Last edited by MikeCyber; August 22nd, 2017 at 07:44 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •