Skip to main content
Post Closed as "Duplicate" by Quasímodo, AdminBee, αғsнιη, nohillside, Archemar
deleted 72 characters in body
Source Link
Porcupine
  • 2.2k
  • 4
  • 26
  • 60

I am trying to delete all empty lines after line number 3, till the end of the file:

cat ${File}
1

2
3


4

5

5



6
7



8
9


sed -e '3,${s~^$~~g}' ${File}
1

2
3


4

5

5



6
7



8
9

Observation: No change in the output.

Desired Output

1

2
3
4
5
5
6
7
8
9

Note that all blank lines at the end of file should also be removed.

Any Suggestions?

I am trying to delete all empty lines after line number 3, till the end of the file:

cat ${File}
1

2
3


4

5

5



6
7



8
9


sed -e '3,${s~^$~~g}' ${File}
1

2
3


4

5

5



6
7



8
9

Observation: No change in the output.

Desired Output

1

2
3
4
5
5
6
7
8
9

Note that all blank lines at the end of file should also be removed.

Any Suggestions?

I am trying to delete all empty lines after line number 3, till the end of the file:

cat ${File}
1

2
3


4

5

5



6
7



8
9


sed -e '3,${s~^$~~g}' ${File}
1

2
3


4

5

5



6
7



8
9

Observation: No change in the output.

Desired Output

1

2
3
4
5
5
6
7
8
9

Any Suggestions?

edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265
Remove irrelevant tag
Source Link
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

I am trying to delete all empty lines after line number 3, till the end of the file:

cat ${File}
1

2
3


4

5

5



6
7



8
9


sed -e '3,${s~^$~~g}' ${File}
1

2
3


4

5

5



6
7



8
9

Observation: No chamgechange in the output.

Desired Output

1

2
3
4
5
5
6
7
8
9

Note that all blank lines at the end of file should also be removed.

Any Suggestions?

I am trying to delete all empty lines after line number 3, till the end of the file:

cat ${File}
1

2
3


4

5

5



6
7



8
9


sed -e '3,${s~^$~~g}' ${File}
1

2
3


4

5

5



6
7



8
9

Observation: No chamge in the output.

Desired Output

1

2
3
4
5
5
6
7
8
9

Note that all blank lines at the end of file should also be removed.

Any Suggestions?

I am trying to delete all empty lines after line number 3, till the end of the file:

cat ${File}
1

2
3


4

5

5



6
7



8
9


sed -e '3,${s~^$~~g}' ${File}
1

2
3


4

5

5



6
7



8
9

Observation: No change in the output.

Desired Output

1

2
3
4
5
5
6
7
8
9

Note that all blank lines at the end of file should also be removed.

Any Suggestions?

Source Link
Porcupine
  • 2.2k
  • 4
  • 26
  • 60
Loading