Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
LemonWiki共筆
Search
Search
Appearance
Log in
Personal tools
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Troubleshooting of SonarQube issue
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== How to resolve "Add a new line at the end of this file." === Error message: Files should contain an empty newline at the end<ref>[https://gist.github.com/OleksiyRudenko/d51388345ea55767b7672307fe35adf3 Why should text files end with a newline?]</ref> Solution: * Add [[Return symbol | new line]] at the end of this file Another solution: * Add an new file {{kbd | key=add_newline_to_php_files.sh}} with the following content <pre> #!/bin/bash # Check if a directory path argument has been provided if [ "$#" -ne 1 ]; then echo "Usage: ./add_newline_to_php_files.sh [Directory Path]" exit 1 fi # Retrieve the directory path argument dir_path="$1" # Initialize a counter for modified files modified_count=0 # Iterate through all .php files in the specified directory for file in "$dir_path"/*.php; do # Check if the file exists if [ -f "$file" ]; then # Read the last line of the file last_line=$(tail -n 1 "$file") # Check if the last line is empty if [ "$last_line" != "" ]; then # If it's not empty, append a newline character echo "" >> "$file" # Increment the modified files counter ((modified_count++)) fi fi done # Display the number of modified files echo "Number of modified files: $modified_count" </pre> * Grant the execution permission {{kbd | key=chmod +x add_newline_to_php_files.sh}} * Usage {{kbd | key=<nowiki>./add_newline_to_php_files.sh /path/to/php/directory_of_scripts</nowiki>}}
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki共筆:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)