Hacker News new | past | comments | ask | show | jobs | submit login

If a file has a line ending in it, is it truly empty?

The -n flag keeps echo from emitting a line ending.

doh! I read it as \n, but then that's for other languages, so i was just all sorts of not paying attention

I used a distro in recent memory where `echo -n foo` really produced `-n foo`.

The workaround was `printf "%s" foo`.

Ah yeah, posix doesn't require -n to do anything in particular. For most use cases, strict adherence to posix compatibility isn't important, but sometimes it really really is.

Registration is open for Startup School 2019. Classes start July 22nd.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact