Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Hot answers tagged

76 votes

How to remove empty/blank lines from a file in Unix (including spaces)?

grep Simple solution is by using grep (GNU or BSD) command as below. Remove blank lines (not including lines with spaces). grep . file.txt Remove completely blank lines (including lines with ...
user avatar
  • 5,797
9 votes

How to remove empty/blank lines from a file in Unix (including spaces)?

To remove empty lines, you could squeeze new line repeats with tr: cat file.txt | tr -s '\n' '\n'
user avatar
  • 191
8 votes

Best way to remove text from the beginning of a huge file

bunzip2 -c backup.sql.bz2 | \ sed -n '/-- Table structure for `mytable`/,$p' Explanation: -n suppress automatic printing of pattern space Address range construction: Start with regex /-- Table ...
user avatar
  • 17.6k
7 votes

How to decipher Powershell syntax for text formatting?

Select-Object can use a hash table of Header/Values for each item. In this example: Select-Object Name, @{Name="Size In KB";Expression={ "{0:N0}" -f ($_.Length / 1KB)}} ... the script is selecting ...
user avatar
5 votes

How do I grep through binary files that look like text?

You can use these three commands: grep -a <sth> file.txt cat -v file.txt | grep <sth> cat file.txt | tr '[\000-\011\013-\037\177-\377]' '.' | grep <sth>
user avatar
  • 203
3 votes

Nginx serves php files as plain text (Mod_Rewrite)

The problem here is that you used an online utility to "convert" from Apache to nginx, and none of these do very well. if (!-e $request_filename){ rewrite ^(.*)$ /index.php?/$0 break; } This needs ...
user avatar
2 votes

How to decipher Powershell syntax for text formatting?

@{...=...; ...=...} is a hashtable. You may know of them as "dictionaries" in other languages. These are key/value pairs. Semicolons (;) separate the different pairs, and the key and value are ...
user avatar
  • 141
2 votes

How to decipher Powershell syntax for text formatting?

I agree with all other answers, the hash-table being a calculated property in this case. I find these one liners wonderful, but they could be presented in a far better way. Technical still a one-liner ...
user avatar
  • 1,015
2 votes

How to decipher Powershell syntax for text formatting?

What you're missing is that @{...} indicates a hashtable array, which are composed of key-value pairs. As pointed out in the comments, there's a Technet article on this very thing. In your example, ...
user avatar
  • 53.2k
2 votes

Best way to remove text from the beginning of a huge file

NOTE: Not an actual answer Since I was motivated to get this solved now, I went ahead and used grep to find the offset in the file I wanted; it worked great. Running dd unfortunately requires that you ...
user avatar
2 votes

Display first few characters of first few lines of a text file

cat /etc/passwd| cut -b -6 will give you the first 6 characters of each line of /etc/passwd file You may add a | head -9 to read only the first nine lines.
user avatar
  • 6,603
1 vote
Accepted

Risks to increasing the IIS 7 --"Maximum Requesting Entity Body Limit"

Copied from the comment. Usually the relevant IIS settings are set to prevent common security vulnerabilities. In your case, if I know your site, and you are using such a setting, I can easily DDOS ...
user avatar
  • 830
1 vote
Accepted

Prevent using cleartext passwords in e-mail protocols?

If your Mail provider support it, you should always use the Secured version of the protocols : POPS, IMAPS and SMTPS. All are encrypted and wireshark will not be able to understand anything.
user avatar
  • 6,603
1 vote

Corrupted text file recovery (Win7 x64)

Short answer: Nope. Long answer: Notepad does not operate from the disk. When you open a txt file, it loads the entire file into memory (this is why Notepad is so slow when opening large files, ...
user avatar
  • 1,854
1 vote

How to remove empty/blank lines from a file in Unix (including spaces)?

xargs if you dont mind stripping leading whitespace $ docker run -it --rm alpine sh / # cat <<eof > /tmp/file > one > > two > three > > > four > eof / # cat /tmp/...
user avatar
1 vote

How to remove empty/blank lines from a file in Unix (including spaces)?

Ex/Vim Here is the method using ex editor (part of Vim): ex -s +'v/\S/d' -cwq test.txt For multiple files (edit in-place): ex -s +'bufdo!v/\S/d' -cxa *.txt Note: The :bufdo command is not POSIX. ...
user avatar
  • 5,797

Only top scored, non community-wiki answers of a minimum length are eligible