Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6228175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:20:37+00:00 2026-05-24T09:20:37+00:00

I am creating a .bash_profile script, and I have run into a small problem.

  • 0

I am creating a .bash_profile script, and I have run into a small problem.

Here is a snippet of my code:

echo -n "Welcome "
whoami
echo -n "!"

I would like the output to give something like this:

Welcome jsmith!

… instead of this:

Welcome jsmith
!

How can I get all of this onto one line?

Any help is greatly appreciated. If it helps, I’m using the Bash Shell, on Ubuntu Server 10.04 LTS.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:20:39+00:00Added an answer on May 24, 2026 at 9:20 am

    You can insert $(command) (new style) or `command` (old style) to insert the output of a command into a double-quoted string.

    echo "Welcome $(whoami)!"
    

    Note: In a script this will work fine. If you try it at an interactive command line the final ! may cause you trouble as ! triggers history expansion.

    Command Substitution

    Command substitution allows the output of a command to replace the command name. There are two forms:

    $(command)
    

    or

    `command`
    

    Bash performs the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing newlines deleted [emphasis added].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am in the process of creating a bash script that would log into
Aloha everyone, I have created a small bash shell script which I wanted to
For creating configuration of my application I need to run bash script. Is it
I'm creating a bash script to create new EC2 instances and then upload a
I am creating a bash script for generating certificates. The openssl command that creates
I wrote a short bash script to complete a task that involves creating a
I am creating a bash script to backup my files with rsync. Backups all
I'd like to request some help in creating a Batch file to run on
I wanted to share here a useful script of mine. I am developing some
I'm creating a bash script that will load CSV files using SQL*Loader. Please refer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.