I want to be able to print out my logs with extra new lines.
This is what the logs look like
2021/04/29 12:30:19 [error] 30098#30098: *443497 FastCGI sent in stderr: "PHP message: PHP Warning: Use of undefined constant last_login - assumed 'last_login' (this will throw an Error in a future version of PHP) in /var/www/html/app/addons/my_changes/func.php on line 9PHP message: PHP Notice: Array to string conversion in /var/www/html/app/addons/my_changes/func.php on line 9" while reading response header from upstream, client: 172.70.34.13, server: www.example.com, request: "GET /Total-9-Abrasive-Grinding-Disc-TAC2232301 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.3-fpm.sock:", host: "www.example.com"
2021/04/29 12:30:24 [error] 30098#30098: *443501 FastCGI sent in stderr: "PHP message: PHP Warning: Use of undefined constant last_login - assumed 'last_login' (this will throw an Error in a future version of PHP) in /var/www/html/app/addons/my_changes/func.php on line 9PHP message: PHP Notice: Array to string conversion in /var/www/html/app/addons/my_changes/func.php on line 9" while reading response header from upstream, client: 172.70.34.73, server: www.example.com, request: "GET /Kitchen-and-Dinning/Tableware/Glass/Luminarc-Tumbler-6pcs-Scotland-33cl-N0763?sort=rating&order=DESC&limit=100 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.3-fpm.sock:", host: "www.example.com"
2021/04/29 12:30:25 [error] 30098#30098: *443503 FastCGI sent in stderr: "PHP message: PHP Warning: Use of undefined constant last_login - assumed 'last_login' (this will throw an Error in a future version of PHP) in /var/www/html/app/addons/my_changes/func.php on line 9PHP message: PHP Notice: Array to string conversion in /var/www/html/app/addons/my_changes/func.php on line 9" while reading response header from upstream, client: 141.101.105.129, server: www.example.com, request: "GET /index.php?dispatch=product_features.add_product&product_id=9534&redirect_url=index.php%3Ffeatures_hash=1-877%26sort_by=popularity%26sort_order=desc%26layout=short_list%26dispatch=categories.view%26category_id=30%26page=15 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.3-fpm.sock:", host: "www.example.com"
They look much cluttered in the terminal and although there is a newline, I want to add 1 more newline to make it more readable.
I tried using
tail -n 10 /var/log/nginx/example.com_error.log | sed 's/n/nn/g'
and
tail -n 10 /var/log/nginx/example.com_error.log | tr 'n' 'nn'
to no avail.
2
Answers
$
means end-of-line insed
.Not entirely certain about portability, but the open group specs (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pr.html#tag_20_93_01) state:
and
so it’s pretty standard.