Jajan's code worked flawless for me. Do you mind posting a helpful output of the error you got? Having 316 posts in this forum, you should be familiar giving detailed answers to solve your problems, thanks.
My problem is I didn't get an error. I got a ton of blank lines. The file has 4.5k of lines. I'm not sure what the preferred method is to deal with huge files.
Here is 100 of the lines.
# Video filter module (string)
#video-filter=
# Video output filter module (string)
#vout-filter=
# Enable sub-pictures (boolean)
#spu=1
# On Screen Display (boolean)
#osd=1
# Text rendering module (string)
#text-renderer=
# Use subtitle file (string)
#sub-file=
# Autodetect subtitle files (boolean)
#sub-autodetect-file=1
# Subtitle autodetection fuzziness (integer)
#sub-autodetect-fuzzy=3
# Subtitle autodetection paths (string)
#sub-autodetect-path=./Subtitles, ./subtitles
# Force subtitle position (integer)
#sub-margin=0
# Subpictures filter module (string)
#sub-filter=
# Program (integer)
#program=0
# Programs (string)
#programs=
# Audio track (integer)
#audio-track=-1
# Subtitles track (integer)
#sub-track=-1
# Audio language (string)
#audio-language=
# Subtitle language (string)
#sub-language=
# Audio track ID (integer)
#audio-track-id=-1
# Subtitles track ID (integer)
#sub-track-id=-1
# Input repetitions (integer)
#input-repeat=0
# Start time (float)
#start-time=0.000000
# Stop time (float)
#stop-time=0.000000
# Run time (float)
#run-time=0.000000
# Fast seek (boolean)
#input-fast-seek=0
# Playback speed (float)
#rate=1.000000
# Input list (string)
#input-list=
# Input slave (experimental) (string)
#input-slave=
# Bookmarks list for a stream (string)
#bookmarks=
# DVD device (string)
#dvd=/dev/dvd
# VCD device (string)
#vcd=/dev/cdrom
# Audio CD device (string)
#cd-audio=/dev/cdrom
# UDP port (integer)
#server-port=1234
# MTU of the network interface (integer)
#mtu=1400
# Force IPv6 (boolean)
#ipv6=0
Carriage returns (\r) are not part of a regular Unix file and a linefeed (\n) cannot be matched by regular grep, since grep is line based. + is part of an extended regular expression (ERE) so you would need to use grep -E
Ok. That's good to know. I suppose the end of line anchor ($) will work, then.
This seems to work on a tiny test file.
grep -e '^[^#]*$' testhash.txt
EDIT:
This is my file contents:
line1 has some text
line2 is a second line
li#e3 has a hash!
line4 the above line had a hash!
line# has a hash too
line6 - ^ had a hash.. bad line?
#ine7 hashline
line8 lastly the last line
#
line11 single hash and a blank line above
And this is the output:
line1 has some text
line2 is a second line
line4 the above line had a hash!
line6 - ^ had a hash.. bad line?
line8 lastly the last line
line11 single hash and a blank line above
But that would also filter out lines that use the # symbol somewhere on the line either as a partial comment or not as a comment. It also does not filter out empty lines..
To compare:
$ cat infile
# This is a test
echo hello # partial test
echo the line above contains tabs and spaces
echo the line above is empty
echo "just want to print an #i character" ffsf
$ grep -e '^[^#]*$' infile
echo the line above contains tabs and spaces
echo the line above is empty
$ awk 'NF && $1!~/^#/' infile
echo hello # partial test
echo the line above contains tabs and spaces
echo the line above is empty
echo "just want to print an #i character" ffsf
$