Skip to main content
added 182 characters in body
Source Link
DisplayName
  • 12.1k
  • 21
  • 78
  • 121

Like a reverse of awk 'NR==2 {print ""} 1 which adds a new line under the first and prints whatever there. I can't replace the number after NR== with a fixed value because I want to be able to do this at file including any amount of lines. I mean I suppose I could do something that counts the amount of lines and then make a variable which is the number of the second last line, but I don't want to "reinvent the wheel".

Example input:

1
2
3
4

Example output:

1
2
3
something added here
4

Like a reverse of awk 'NR==2 {print ""} 1 which adds a new line under the first and prints whatever there. I can't replace the number after NR== with a fixed value because I want to be able to do this at file including any amount of lines.

Example input:

1
2
3
4

Example output:

1
2
3
something added here
4

Like a reverse of awk 'NR==2 {print ""} 1 which adds a new line under the first and prints whatever there. I can't replace the number after NR== with a fixed value because I want to be able to do this at file including any amount of lines. I mean I suppose I could do something that counts the amount of lines and then make a variable which is the number of the second last line, but I don't want to "reinvent the wheel".

Example input:

1
2
3
4

Example output:

1
2
3
something added here
4
Source Link
DisplayName
  • 12.1k
  • 21
  • 78
  • 121

Make new line above last line and add something there

Like a reverse of awk 'NR==2 {print ""} 1 which adds a new line under the first and prints whatever there. I can't replace the number after NR== with a fixed value because I want to be able to do this at file including any amount of lines.

Example input:

1
2
3
4

Example output:

1
2
3
something added here
4