@tifu
Unfortunately, you can't do this as a "one-liner" from the shell, because of the shell's weakness: it won't allow single quotes (apostrophes) inside other single quotes, even if preceded by a backslash!
But, you can easily overcome this. Just change the "one-liner" to it's own perl script!
Code:
#!/usr/bin/perl
open FILE, "file1" or die "Couldn't open file1 because: $!\n";
while (<FILE>) {
tr/A-Za-z\ \n\-\\'//cd; # Deletes characters we didn't specify
s/^\s+//; # Delete leading whitespace
s/\s+/\n/g; # Changes all spaces to one new line
s/(\w)/\L$1/g; # Changes letters to lowercase
print;
}
And run it from your shell.
If you want to allow other things, like @ symbols for example, just change the line
tr/A-Za-z\ \n\-\\'//cd;
to
tr/\'\@A-Za-z\ \n\-\\'\@//cd;
Get the idea? Behold the power of perl!
Edit: Oops, should have put a "\" in front of the "-" originally...