Removing a newline character at the end of a file

A simpler solution than the accepted one: truncate -s -1 <<file>> From the truncate man page (man truncate): -s, –size=SIZE set or adjust the file size by SIZE SIZE may also be prefixed by one of the following modifying characters: ‘+’ extend by, ‘-‘ reduce by, ‘<‘ at most, ‘>’ at least, “https://stackoverflow.com/” round down … Read more

Character Translation using Python (like the tr command)

See string.translate import string “abc”.translate(string.maketrans(“abc”, “def”)) # => “def” Note the doc’s comments about subtleties in the translation of unicode strings. And for Python 3, you can use directly: str.translate(str.maketrans(“abc”, “def”)) Edit: Since tr is a bit more advanced, also consider using re.sub.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)