Posted by: admin Forums. Because the file you source ends lines with carriage returns, the contents of $testVar are likely to look like this: (The first line's $ is the shell prompt; the second line's $ is from the %q formatting string, indicating $'' quoting.). Save my name, email, and website in this browser for the next time I comment. You can remove line breaks from blocks of text but preserve paragraph breaks with this tool.. The sed command allows to perform text manipulation and it can be called as part of your scripts in the same way you can do with other Linux or Unix commands. I wanted to offer up an alternative that I've used in PowerShell. My requirement is to read a line from a file and store it to a string. … your coworkers to find and share information. how to add and remove classes in JS without jquery, Change bootstrap progress-bar width from angularjs, Â© 2014 - All Rights Reserved - Powered by, BASH: Strip new-line character from string (read line). Someone already wrote a program which executes shell commands: sh file, If you really only want to execute the first line of a file: head -n 1 file |sh, If your problem is carriage-returns: tr -d '\r'