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

  • SEARCH
  • Home
  • 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 8325893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:35:16+00:00 2026-06-09T00:35:16+00:00

I have three types of strings that I’d like to capitalize in a bash

  • 0

I have three types of strings that I’d like to capitalize in a bash script. I figured sed/awk would be my best bet, but I’m not sure. What’s the best way given the following requirements?

  1. single word
    e.g. taco -> Taco

  2. multiple words separated by hyphens
    e.g. my-fish-tacos -> My-Fish-Tacos

  3. multiple words separated by underscores
    e.g. my_fish_tacos -> My_Fish_Tacos

  • 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-06-09T00:35:18+00:00Added an answer on June 9, 2026 at 12:35 am

    There’s no need to use capture groups (although & is a one in a way):

    echo "taco my-fish-tacos my_fish_tacos" | sed 's/[^ _-]*/\u&/g'
    

    The output:

    Taco My-Fish-Tacos My_Fish_Tacos
    

    The escaped lower case “u” capitalizes the next character in the matched sub-string.

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

Sidebar

Related Questions

I have a rails application that has three different types of users and I
I have four types of strings, as shown below. The difference is that the
I have the following types of strings. One with three slashes and one with
I have an ArrayList full of strings arrays that I built like this: String[]
I have three types of products - Retail products (ID,product_categoryId,price,name) - Courses (ID,course_categoryId,price,name,roomId) -
I have three fixed width integer types: typedef int16_t TABCellManagedDataKey; typedef int16_t TABCellManagedDataIndex; typedef
Please consider the following three .NET types: I have an interface, an abstract class,
Work on asp.net vs05. I have three type of value Like:IsDesign,IsPrinting,IsInstall they are bit
I have read a document that they say: In java there two types of
Suppose i have input array byte A[50]; i have put three diffrent data types

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.