user1654528
user1654528

Reputation: 395

Using AWK or Sed how can I remove trailing carriage return and a line feeds before first txt

Using AWK or Sed, how can I remove carriage returns and line feeds from the start of a file before first txt.

Before

 TOP OF FILE - Carriage returns and line feeds before txt


 <?xml version="1.0" encoding="UTF-8"?>
 <fredBaa version="1.2" properties="2.8" Baa="2.13 r1665067">
  <hashTree>...

After

TOP OF FILE - No Carriage returns and line feeds before txt
 <?xml version="1.0" encoding="UTF-8"?>
 <fredBaa version="1.2" properties="2.8" Baa="2.13 r1665067">
  <hashTree>...

Upvotes: 2

Views: 1457

Answers (3)

Kent
Kent

Reputation: 195029

does this work for you?

sed '0,/./{/./!d}' file

Upvotes: 1

Ed Morton
Ed Morton

Reputation: 203189

All you need is:

awk 'NF{f=1}f' file

Upvotes: 1

Casimir et Hippolyte
Casimir et Hippolyte

Reputation: 89547

you can try this:

awk '/</{a=1}a' file

or to remove all leading lines until the one that has a non-blank character:

awk '/[^[:space:]]/{a=1}a' file

Upvotes: 1

Related Questions