简体   繁体   中英

Remove newline character in bash

I'm writing a script to automatically manage my git email configuration. 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. 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:

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 :

Options:
-n do not append a newline
-e enable interpretation of the following backslash escapes
-E explicitly suppress interpretation of backslash escapes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM