delete empty lines
Take out the empty lines of a file, also the ones with only spaces.
text
steps
-
sed -i '/^$/d' file.txtdelete the empty lines
-
sed -i '/^[[:space:]]*$/d' file.txtalso the lines with only spaces or tabs
-
grep -v '^$' file.txt > new.txtwrite the file without them to a new one
-
awk 'NF' file.txtshow it without empty or blank lines
notes
- macOS:
sed -i ''in place ofsed -i.
commands used
sedgrepawk
Each has a page in lore: lore sed opens it.
add up numbers in a file
Sum a column of numbers, from a file or a command's output.
compare two folders
Find which files differ between two folders, or are only in one of them.
count lines of code
How many lines of code a project has, in total and by language.
count lines, words and files
Count the lines of a file or of a command's output, the words, and the files in a folder.