logo
down
shadow

Capitalize words in a bash variable using sed


Capitalize words in a bash variable using sed

By : user2952517
Date : November 19 2020, 01:01 AM
This might help you I am totally new on shell scripting (actually three days only :) ) so don't shoot me .. !!
code :
string=$(sed 's/^./\u&/; s/-\(.\)/ \u\1/g' <<< $string)
sdlcb@Goofy-Gen:~/AMD$ cat File
#!/bin/bash

string="this-is-my-string"
string=$(sed 's/^./\u&/; s/-\(.\)/ \u\1/g' <<< $string)    
echo "$string"

AMD$ ./File
This Is My String


Share : facebook icon twitter icon
capitalize words with some words inside of tags

capitalize words with some words inside of tags


By : Mun-Kyo Seo
Date : March 29 2020, 07:55 AM
I wish this helpful for you A quick look into PHP's documentation brought this up.
And after a short test, I can confirm, that this line does the trick for your example (I don't know about any other specific cases you might have, though):
code :
$str = '<span class="lsres">retro</span> VIRUS';
echo mb_convert_case($str, MB_CASE_TITLE, "UTF-8");
How do I capitalize all words in a string apart from small words in the middle and in the beginning?

How do I capitalize all words in a string apart from small words in the middle and in the beginning?


By : dejoker
Date : March 29 2020, 07:55 AM
may help you . This will capitalize all the words, except for the stop words (your small words) that aren't the first in the sentence.
code :
def title(sentence)
  stop_words = %w{a an and the or for of nor} #there is no such thing as a definite list of stop words, so you may edit it according to your needs.
  sentence.split.each_with_index.map{|word, index| stop_words.include?(word) && index > 0 ? word : word.capitalize }.join(" ")
end
Capitalize bash variable

Capitalize bash variable


By : hibaza
Date : March 29 2020, 07:55 AM
I hope this helps you . Just store above command's output in a variable using command substitution:
code :
s=$(echo "Manufacturer: $(echo ${family:-$name}|cut -d' ' -f1)")
echo "${s^^}"
lowercase + capitalize + concatenate words of a string in shell (e.g. bash)

lowercase + capitalize + concatenate words of a string in shell (e.g. bash)


By : Phil
Date : March 29 2020, 07:55 AM
will be helpful for those in need String manipulation available in version 4:
${variable,,} to lowercase all letters ${variable^} to uppercase first letter of each word use ${words[*]^} instead of ${words[@]^} to save some script lines
code :
capitalize_remove_spaces()
{
  local words IFS
  read -ra words <<< "${@,,}"
  IFS=''
  echo "${words[*]^}"
}
capitalize_remove_punctuation()
{
  local words IFS=$' \t\n-\'.,;!:*?' #Handle hyphenated names and punctuation
  read -ra words <<< "${@,,}"
  IFS=''
  echo "${words[*]^}"
}
> capitalize_remove_spaces 'jAMeS bOnD'
JamesBond

> capitalize_remove_spaces 'jAMeS bOnD *'
JamesBond*

> capitalize_remove_spaces 'Jean-luc GRAND-PIERRE'
Jean-lucGrand-pierre

> capitalize_remove_punctuation 'Jean-luc GRAND-PIERRE'
JeanLucGrandPierre

> capitalize_remove_punctuation 'Jean-luc GRAND-PIERRE *'
JeanLucGrandPierre
how to capitalize the input in TextInput in react native? i cant capitalize the sentence, words or characters by autoCap

how to capitalize the input in TextInput in react native? i cant capitalize the sentence, words or characters by autoCap


By : Syed
Date : March 29 2020, 07:55 AM
I hope this helps . I noticed that this happens only on my samsung default keyboard. I downloaded another keyboards and autoCapitalize was working on other keyboards.
Related Posts Related Posts :
  • grep file with full contain string
  • merge two regular expressions in vs2010
  • Get substring up until the first question mark
  • Regular expression to match part of word
  • editing a JSON file with sed
  • R: RegEx for coordinates
  • Regex 5 digits number from Subject Line in MS Outlook
  • PERL: Matching multiple patterns
  • Extract location data using regex in R
  • Extracting Dates Using Regular Expression in R using grepl
  • Regex with multiple optional groups
  • Pseudo currency regex
  • Subject to permlink convertion in bash
  • Regular expression replace all occurrences of any word beginning with a certain substring
  • Umbraco 7 regex error: Value is invalid, it does not match the correct pattern
  • Regex using Vala and GLib
  • How to match multi-row data using regular expression R programming
  • Find last 30 occurrences of a string in a log file using Perl
  • How to use regex in bash for selecting a string between double quotes?
  • Golang to match dash(hyphen) character
  • How to express a escape sequence in regex. ("" -> ")
  • Regular Expression - Perl
  • Regex That Pulls Certain Bits From a String
  • Regex: This or that or none
  • Copying text from one line to another
  • find string that consists only of a certain set of characters
  • Sublime Text 3: How to change the notation from ``->cls`` to some macro?
  • VBScript Return an entire line when searching for a string
  • Unwind array of objects mongoDB
  • To delete the last character with regex
  • Understanding negative lookahead
  • How can I exclude a string if it ends in ".d.ts"?
  • Need help regarding forming a regular expression -xml
  • Using sed to replace string in file by using regex capture group
  • How to match a sequence of whitespaces with c++11 regex
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org