Hongmu Notes
Home Summary of pitfalls Linux replaces multiple line breaks with a single line break.
Summary of pitfalls

Linux replaces multiple line breaks with a single line break.

Linux replaces multiple line breaks with a single line break.

I met a disgusting person who asked me to change a code for 80 yuan, and he had to modify it remotely. It was originally a calling problem of the PHP backend. OK, let’s change it. But this guy saw that I finished it in a few minutes, so he asked me to modify the front-end page for him. I was speechless!

He only charges money for one question, but he wants to give money to one question for a bunch of questions. Is he really a technical cabbage?

I have dealt with a lot before. Every time I change something, I keep bargaining. When I modify someone's website or something, the starting price is 200. This guy lowers the price for me every time. I think he has a hard life, so I give him half the price. I will get it for 100. But this guy is ungrateful and wants to bargain. Is 50 okay? I ignored him, and after a while, 80, 80, help me get it done!

I said yes, then it would be 80. After I finished correcting the 80 problem, he started BBing again, no! There is another problem here, please help me fix it together!

I said yes, so I changed it for him. Maybe I was too kind. Damn it, every time I changed it, for a front-end problem, he insisted on asking me to change the back-end, and for a back-end problem, he insisted on me changing the front-end. In short, it was just money for one problem. He asked me to change two or three problems, but I refused, and then he said I was unreasonable!

hehe!

Today I finally couldn't stand it anymore!

After watching me change the code, I started to bb again, and started asking me to correct other problems. I said before, modify the back-end call, not including the modification of the front-end! He also scolded me for being dishonest and not doing anything after receiving money?

I actually threw up, it was so disgusting! I have been helping people modify their websites sporadically on the Internet for five or six years. I have solved hundreds of thousands of problems. I think the webmasters on the Internet are very considerate, but now I have broken the defense, brothers!

Linux replaces multiple line breaks with a single line break.

find . -name "*.php" -type f -exec sed -i 'N;/^\n$/d;P;D' {} +

This code uses the GNU find and sed commands to process PHP files in the current directory.

The specific explanation is as follows:

  1. find . -name "*.php":Use the find command to find all PHP files in the current directory and output the results to standard output.
  2. -type f:Specifies to search for files rather than directories or links.
  3. -exec sed -i 'N;/^\n$/d;P;D' {} +:Use the sed command to process each PHP file found. in,NIndicates to continue typing on a new line,/^\n$/dIndicates deleting the first and last lines,PIndicates copying the file contents to the buffer,DReplaces the buffer contents with the current line.{}Indicates the file name to be processed,+Indicates processing multiple files.
  4. -name "*.php":Use the find command again to find all PHP files in the current directory and output the results to standard output.

It should be noted that in this code-type fParameters may be ignored becausefind . -name "*.php"All PHP files can now be found. In addition, since the syntax of the sed command is relatively complex, it is recommended to check the syntax carefully to ensure the correctness of the code.

 

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Browser caching increases the speed of secondary visits to your website

Browser caching increases the speed of secondary visits to your website Summary of pitfalls

Use browser caching of official words: If users will visit your website multiple times, browser caching of static resources can save users time. Cache headers should be applied to all cacheable static resources, not just to a small subset of static resources (for example, images). Cacheable resources include JS and CSS files, image files, and other binary object files (media files, PDF files, etc.). Normally, HTML doesn’t…
👁 202

Recommended reading

(PC+WAP) Steel Pipe, Steel Materials, Hardware & Metal – Website Template 1015

(PC+WAP) Steel Pipe, Steel Materials, Hardware & Metal – Website Template 1015 Practical Collection pbootcms Template

A PbootCMS website template designed for steel pipes, steel products, and hardware metals, compatible with both PC and WAP devices. The professional industrial design is ideal for showcasing steel pipe, steel, and metal hardware products. It enables metal materials enterprises to showcase their product ranges online and attract industrial and construction clients. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn | Related Articles...
👁 44
(Adaptive mobile version) Responsive blue eco-friendly equipment website – PBootCMS template; Download source code for environmental engineering equipment websites – 0313

(Adaptive mobile version) Responsive blue eco-friendly equipment website – PBootCMS template; Download source code for environmental engineering equipment websites – 0313 Practical Collection pbootcms Template

An adaptive, responsive blue eco-friendly equipment and system engineering PbootCMS website template. Featuring a professional, tech-driven design style, this template is ideal for environmental protection companies to showcase their equipment, project cases, and technical solutions. It helps environmental enterprises build their brand image online and secure project contracts. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5...
👁 64
PHP reads the content of a text file line by line, outputs 100 lines at a time, and supports paginated output.

PHP reads the content of a text file line by line, outputs 100 lines at a time, and supports paginated output. Language Notes PHP

You have a TXT file containing one million titles, with one title per line. Each time you access the file, you are passed a `pageid`; when `pageid` is 1, the first to 100 titles in the file are output; when `pageid` is 2, the 101st to 200th titles are output; and so on. The PHP code is also very simple: 🔒 Hidden content: Members can view <?php // Open the title file $ha...
👁 173
Air entrainment

Air entrainment Hobbies Memo notes

1. Qinglong Tail Swinging: Tonifying technique, needle tail, shaking left and right, 9 times back and forth, targeting lumps and hard lumps, directly reaching the organs. 2. White Tiger Shaking Head: Diarrhea technique, retreating from square to round, where there are many muscles, original acupoint or main acupoint. 3. Canggui Acupoint: Tonifying technique, one retreat and three advance, when entering, divide it into three times, and retreat once. 4. Red Phoenix welcomes the source: The technique of purging, shaking the needle handle while retreating from the square and entering the circle, also called Red Phoenix shaking its head. 5. Battle between dragon and tiger: three parts (heaven, man and earth), each...
👁 230
Video tutorial – Paid knowledge-based software download website template 0561

Video tutorial – Paid knowledge-based software download website template 0561 Practical Collection Yiyou template

An eyoucms website template for video tutorial knowledge payment and software download. Design style knowledge and technology, able to display video tutorials, knowledge courses, software downloads and membership services. Helps education and training or technical resource platforms to provide knowledge services online. Template display Installation instructions Website backend: /login.php Account: admin Password: admin Related articles Yiyou CMS installation FAQ summary Yiyou...
👁 44
(Independent Mobile Version) Single-Page Landing Page Promotion Website Template – Includes Copyable WeChat ID: 1016

(Independent Mobile Version) Single-Page Landing Page Promotion Website Template – Includes Copyable WeChat ID: 1016 Practical Collection pbootcms Template

An independent mobile-only single-page landing page promotion template for PbootCMS websites, featuring a WeChat ID copying function. The design adopts a strongly marketing-oriented approach, making it ideal for high-conversion landing pages used in WeChat marketing, community promotion, and other scenarios. This template enables businesses to quickly create mobile promotional pages and facilitates users in copying WeChat IDs to drive conversions. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www....
👁 57