Skip to main content
edited title
Link

How to delete columns with zero value in each line?

added 56 characters in body
Source Link
Siva
  • 9.3k
  • 9
  • 60
  • 88

I have a file containing numeric data. Each line has a varying number of columns. In each line, I want to delete the columns containing 0.

Below is a sample Input 25 60 0 29 0 10 23 0 26 43 49 1 56 7 0 21 0 64 3

25 60 0
29 0 10
23 0
26 43 49
1 56 7 0
21 0 64 3

Target Output 25 60 29 10 23 26 43 49 1 56 7 21 64 3

25 60
29 10
23
26 43 49
1 56 7
21 64 3

I have file containing numeric data. Each line has varying number of columns. In each line, I want to delete the columns containing 0.

Below is a sample Input 25 60 0 29 0 10 23 0 26 43 49 1 56 7 0 21 0 64 3

Target Output 25 60 29 10 23 26 43 49 1 56 7 21 64 3

I have a file containing numeric data. Each line has a varying number of columns. In each line, I want to delete the columns containing 0.

Below is a sample Input

25 60 0
29 0 10
23 0
26 43 49
1 56 7 0
21 0 64 3

Target Output

25 60
29 10
23
26 43 49
1 56 7
21 64 3
Source Link

How to columns with zero value in each line?

I have file containing numeric data. Each line has varying number of columns. In each line, I want to delete the columns containing 0.

Below is a sample Input 25 60 0 29 0 10 23 0 26 43 49 1 56 7 0 21 0 64 3

Target Output 25 60 29 10 23 26 43 49 1 56 7 21 64 3