Skip to main content
deleted 1 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 123
  • 242

to directly remove the lines you could:

sed -rinri '/.{4}/!d' /path/to/file 

Or BRE:

sed -i '/.\{4\}/!d' /path/to/file 

If a line does not contain 4 or more characters it is deleted.

f=/path/to/file cat <<GREP >"$f" $(grep -E ".{4}" "$f") GREP 

Doing the above in command-substitution subshell will ensure that grep gets a read descriptor on it before cat starts writing to it, but the <<HEREDOC will also ensure that the result remains streamed and does not cause argument length errors.

to directly remove the lines you could:

sed -rin '/.{4}/!d' /path/to/file 

Or BRE:

sed -i '/.\{4\}/!d' /path/to/file 

If a line does not contain 4 or more characters it is deleted.

f=/path/to/file cat <<GREP >"$f" $(grep -E ".{4}" "$f") GREP 

Doing the above in command-substitution subshell will ensure that grep gets a read descriptor on it before cat starts writing to it, but the <<HEREDOC will also ensure that the result remains streamed and does not cause argument length errors.

to directly remove the lines you could:

sed -ri '/.{4}/!d' /path/to/file 

Or BRE:

sed -i '/.\{4\}/!d' /path/to/file 

If a line does not contain 4 or more characters it is deleted.

f=/path/to/file cat <<GREP >"$f" $(grep -E ".{4}" "$f") GREP 

Doing the above in command-substitution subshell will ensure that grep gets a read descriptor on it before cat starts writing to it, but the <<HEREDOC will also ensure that the result remains streamed and does not cause argument length errors.

added 341 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 123
  • 242

to directly remove the lines you could:

sed -rin '/.{4}/!d' /path/to/file 

Or BRE:

sed -i '/.\{4\}/!d' /path/to/file 

If a line does not contain 4 or more characters it is deleted.

f=/path/to/file cat <<GREP >"$f" $(grep -E ".{4}" "$f") GREP 

Doing the above in command-substitution subshell will ensure that grep gets a read descriptor on it before cat starts writing to it, but the <<HEREDOC will also ensure that the result remains streamed and does not cause argument length errors.

to directly remove the lines you could:

sed -rin '/.{4}/!d' /path/to/file 

Or BRE:

sed -i '/.\{4\}/!d' /path/to/file 

If a line does not contain 4 or more characters is deleted.

to directly remove the lines you could:

sed -rin '/.{4}/!d' /path/to/file 

Or BRE:

sed -i '/.\{4\}/!d' /path/to/file 

If a line does not contain 4 or more characters it is deleted.

f=/path/to/file cat <<GREP >"$f" $(grep -E ".{4}" "$f") GREP 

Doing the above in command-substitution subshell will ensure that grep gets a read descriptor on it before cat starts writing to it, but the <<HEREDOC will also ensure that the result remains streamed and does not cause argument length errors.

Source Link
mikeserv
  • 59.4k
  • 10
  • 123
  • 242

to directly remove the lines you could:

sed -rin '/.{4}/!d' /path/to/file 

Or BRE:

sed -i '/.\{4\}/!d' /path/to/file 

If a line does not contain 4 or more characters is deleted.