[英]Remove newline character in bash
I'm writing a script to automatically manage my git email configuration. 我正在编写一个脚本来自动管理我的git电子邮件配置。 Within my script I would like to output a message notifying the user that the email configuration has changed.
在我的脚本中,我想输出一条消息,通知用户电子邮件配置已更改。 I am using the command
git config user.email
to get the new email address. 我正在使用命令
git config user.email
来获取新的电子邮件地址。 However, it prints it to a newline. 但是,它将其打印到换行符。 I would like to print it to the same line as my message.
我想将其打印到邮件的同一行。
This is what I have now: 这就是我现在所拥有的:
echo "Email not configured to Work in Work directory.";
git config user.email "myworkemail@myworkemail.com"
echo "Git email configuration has now been changed to "
git config user.email
Just use a subshell substitution like this: 只需使用如下的subshell替换:
echo "Email not configured to Work in Work directory.";
git config user.email "myworkemail@myworkemail.com"
echo "Git email configuration has now been changed to \"$(git config user.email)\""
help echo
: help echo
:
Options:
选项:
-n do not append a newline-n不添加换行符
-e enable interpretation of the following backslash escapes-e启用对以下反斜杠转义的解释
-E explicitly suppress interpretation of backslash escapes-E明确禁止反斜杠转义的解释
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.