PadLeft function in T-SQL

I believe this may be what your looking for: or I haven’t tested the syntax on the 2nd example. I’m not sure if that works 100% – it may require some tweaking – but it conveys the general idea of how to obtain your desired output. EDIT To address concerns listed in the comments… @pkr298 … Read more

How to trim whitespace from a Bash variable?

I have a shell script with this code: But the conditional code always executes, because hg st always prints at least one newline character. Is there a simple way to strip whitespace from $var (like trim() in PHP)? or Is there a standard way of dealing with this issue? I could use sed or AWK, but I’d like to think there is a more elegant … Read more

Reading a file line by line in Go

NOTE: The accepted answer was correct in early versions of Go. See the highest voted answer contains the more recent idiomatic way to achieve this. There is function ReadLine in package bufio. Please note that if the line does not fit into the read buffer, the function will return an incomplete line. If you want to always read a whole line … Read more