HJW
HJW

Reputation: 23453

Linux shell command to append a line of text to all text files (application logs actually)

I would like to append a line of text all text files (*.log) in a directory, reason being, i would like to insert a "marker" text in application logs to insert breakpoints.

Thanks.

Upvotes: 1

Views: 242

Answers (3)

Steve
Steve

Reputation: 54592

One way using a 'for' loop:

for i in *.log; do echo "MARKER" >> "$i"; done

Upvotes: 3

Vijay
Vijay

Reputation: 67319

perl -i -lne 'if(eof){print $_."\MARK"}else{print}' *.log

Upvotes: 1

Guru
Guru

Reputation: 17054

Using sed:

sed -i '$a MARKER' *.log

Upvotes: 0

Related Questions