0

I need to find the first empty line in the text file using the sed command regular expression.

below is the content that I have


this is defile
to be cleaned
skip rest consl

In the above content, I need to find only the first line that is an empty line and delete the first line.

I have used below regular expression, but it did not work for me, it is finding empty lines everywhere in the file.

^\s*$
moong
  • 73
  • 1
  • 1
  • 9

1 Answers1

0

In Java you do something like this:

Pattern pattern = Pattern.compile ("^\\s*$", Pattern.MULTILINE);
Matcher matcher = pattern.matcher ("foo\n  \nbar");
if (matcher.find()) {
    String firstEmptyLine = matcher.group();
    ...
}
Mikhail Vladimirov
  • 13,572
  • 1
  • 38
  • 40