Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Some sed work would do the trick:

  • a sed to remove ANSI color codes

      sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
    
  • a sed to replace space(s) with tabs

      sed -r "s/\s+/\t/g"
    

Finaly:

printf "\033[0;32;1mgreen_apple\033[0m 1 100
orange 20 19
pineapple 1000 87
avocado 4 30" \
| sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" \
| sed -r "s/\s+/\t/g"

Output:

green_apple     1           100
orange          20          19
pineapple       1000        87
avocado         4           30

PS: I honestly tested all this with ls --color output. This is easier than playing with echo.

About removing ANSI color codes:

Some sed work would do the trick:

  • a sed to remove ANSI color codes

      sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
    
  • a sed to replace space(s) with tabs

      sed -r "s/\s+/\t/g"
    

Finaly:

printf "\033[0;32;1mgreen_apple\033[0m 1 100
orange 20 19
pineapple 1000 87
avocado 4 30" \
| sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" \
| sed -r "s/\s+/\t/g"

Output:

green_apple     1           100
orange          20          19
pineapple       1000        87
avocado         4           30

PS: I honestly tested all this with ls --color output. This is easier than playing with echo.

About removing ANSI color codes:

Some sed work would do the trick:

  • a sed to remove ANSI color codes

      sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
    
  • a sed to replace space(s) with tabs

      sed -r "s/\s+/\t/g"
    

Finaly:

printf "\033[0;32;1mgreen_apple\033[0m 1 100
orange 20 19
pineapple 1000 87
avocado 4 30" \
| sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" \
| sed -r "s/\s+/\t/g"

Output:

green_apple     1           100
orange          20          19
pineapple       1000        87
avocado         4           30

PS: I honestly tested all this with ls --color output. This is easier than playing with echo.

About removing ANSI color codes:

replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

Some sed work would do the trick:

  • a sed to remove ANSI color codes

      sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
    
  • a sed to replace space(s) with tabs

      sed -r "s/\s+/\t/g"
    

Finaly:

printf "\033[0;32;1mgreen_apple\033[0m 1 100
orange 20 19
pineapple 1000 87
avocado 4 30" \
| sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" \
| sed -r "s/\s+/\t/g"

Output:

green_apple     1           100
orange          20          19
pineapple       1000        87
avocado         4           30

PS: I honestly tested all this with ls --color output. This is easier than playing with echo.

About removing ANSI color codes:

Some sed work would do the trick:

  • a sed to remove ANSI color codes

      sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
    
  • a sed to replace space(s) with tabs

      sed -r "s/\s+/\t/g"
    

Finaly:

printf "\033[0;32;1mgreen_apple\033[0m 1 100
orange 20 19
pineapple 1000 87
avocado 4 30" \
| sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" \
| sed -r "s/\s+/\t/g"

Output:

green_apple     1           100
orange          20          19
pineapple       1000        87
avocado         4           30

PS: I honestly tested all this with ls --color output. This is easier than playing with echo.

About removing ANSI color codes:

Some sed work would do the trick:

  • a sed to remove ANSI color codes

      sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
    
  • a sed to replace space(s) with tabs

      sed -r "s/\s+/\t/g"
    

Finaly:

printf "\033[0;32;1mgreen_apple\033[0m 1 100
orange 20 19
pineapple 1000 87
avocado 4 30" \
| sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" \
| sed -r "s/\s+/\t/g"

Output:

green_apple     1           100
orange          20          19
pineapple       1000        87
avocado         4           30

PS: I honestly tested all this with ls --color output. This is easier than playing with echo.

About removing ANSI color codes:

added 238 characters in body
Source Link
Ouki
  • 6k
  • 4
  • 25
  • 32

Some sed work would do the trick:

  • a sed to remove ANSI color codes

      sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
    

You can find more

  • a sed to replace space(s) with tabs

      sed -r "s/\s+/\t/g"
    

Finaly:

echoprintf '\033[0;32;1mgreen_apple\033[0m"\033[0;32;1mgreen_apple\033[0m 1 100
orange 20 19
pineapple 1000 87
avocado 4 30'30" \
| sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" \
| sed -r "s/\s+/\t/g"

Output:

green_apple     1           100
orange          20          19
pineapple       1000        87
avocado         4           30

PS: I honestly tested all this with ls --color output. This is easier than playing with echo.

About removing ANSI color codes:

Some sed work would do the trick:

  • a sed to remove ANSI color codes

      sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
    

You can find more

  • a sed to replace space(s) with tabs

      sed -r "s/\s+/\t/g"
    

Finaly:

echo '\033[0;32;1mgreen_apple\033[0m 1 100
orange 20 19
pineapple 1000 87
avocado 4 30' \
| sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" \
| sed -r "s/\s+/\t/g"

About removing ANSI color codes:

Some sed work would do the trick:

  • a sed to remove ANSI color codes

      sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
    
  • a sed to replace space(s) with tabs

      sed -r "s/\s+/\t/g"
    

Finaly:

printf "\033[0;32;1mgreen_apple\033[0m 1 100
orange 20 19
pineapple 1000 87
avocado 4 30" \
| sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" \
| sed -r "s/\s+/\t/g"

Output:

green_apple     1           100
orange          20          19
pineapple       1000        87
avocado         4           30

PS: I honestly tested all this with ls --color output. This is easier than playing with echo.

About removing ANSI color codes:

Source Link
Ouki
  • 6k
  • 4
  • 25
  • 32
Loading