remove line break using AWK
If you are using linux then this will substitute newlines to +
awk '{printf "%s+",$0} END {print ""}'
or with sed
sed ':a;N;$!ba;s/\n/+/g'
awk NF=NF RS= OFS=+
Result
hi+there.hopefully+you+can+get+this+email+which+are+being+send+as+sms.
EDIT: For the solution with awk, you are looking for this:
awk 'BEGIN {RS=""}{gsub(/\n/,"",$0); print $0}' myfile.txt
Another method to strip all newlines from your file:
tr -d "\n"
An example:
tr -d "\n" < myfile.txt > myfilewithoutnewlines.txt
You are doing this the wrong way. You need to URL-encode your text to get a truly universal solution:
When you do this and use a text like this:
This is
a test
text
you end up with this: This+is+%0d%0aa+test+%0d%0atext
.
You can use curl
to do this:
curl -G -d username=<user> -d password=<pass> -d phoneno=$var1 \
--data-urlencode [email protected] \
http://<server_ip>/power_sms/send_sms.php
For more info, see man curl
.
I just wanted to point out in @Sirch sed code you can replace the aforementioned, "+" with any other separator. I hope this helps a few beginners!
example
sed ':a;N;$!ba;s/\n/ /g' #puts 3 spaces between the result