Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shell Removing Tabs/Spaces

Tags:

grep

I've used a grep command with sed and cut filters that basically turns my output to something similar to this

    this line 1


    this line 2


    another line 3


    another line 4

I'm trying to get an output without the spaces in between the lines and in front of the lines so it'd look like

    this line 1
    this line 2
    another line 3
    another line 4

I'd like to add another | filter

like image 474
user1709294 Avatar asked Oct 06 '12 21:10

user1709294


1 Answers

This can be done with the tr command as well. Like so

| tr -s [:space:]

or alternatively

| tr -s \\n

if you want to remove the line breaks only, without the space chars in the beginning of each line.

like image 164
asenovm Avatar answered Sep 20 '22 18:09

asenovm