#] #] ********************* #] "$d_SysMaint"'Linux/str notes.txt' # www.BillHowell.ca 11Sep2023 initial # view in text editor, using constant-width font (eg courier), tabWidth = 3 #48************************************************48 #24************************24 # Table of Contents, generate with : # $ grep "^#]" "$d_SysMaint"'Linux/str notes.txt' | sed "s/^#\]/ /" # #24************************24 # Setup, ToDos, #08********08 #] ??Feb2024 #08********08 #] ??Feb2024 #08********08 #] ??Feb2024 #08********08 #] 01Feb2024 bash str length, add a chr see: str_chrP_rmBetween() - rm chrs between chr[start, end] = chrP, chrP example '{}' in "$d_bin"'strings.sh' +-----+ https://linuxhandbook.com/bash-string-length/ How to Find Length of String in Bash [Quick Tip] Here are various ways to calculate the length of a string in bash scripts. Aug 26, 2020 — Abhishek Prakash ${#my_string} One of these commands is the expr command. It has several options that are useful for string options. Among them, length gives you the length of a string. abhishek@handbook:~$ expr length "my string" 9 You'll have to use echo command and then use pipe redirection to parse it with awk: abhishek@handbook:~$ echo "my string" | awk '{print length}' 9 You can echo the string and pipe it to wc command. The -m option gives the character count. abhishek@handbook:~$ echo -n "my string" | wc -m 9 Notice the -n option with echo command? That is important because echo automatically adds a new line character \n at the end and it will increase the length of the string by one. With -n option, echo command doesn't add new line character. search "Linux bash Segmentation fault (core dumped)" +-----+ https://unix.stackexchange.com/questions/277331/segmentation-fault-core-dumped-to-where-what-is-it-and-why Segmentation fault (core dumped) - to where? what is it? and why? Asked 7 years, 9 months ago Modified 1 year, 7 months ago Viewed 156k times >> too advanced for me - I don't want to wander through a core dump, just want to fix my script (famous last words) +-----+ https://www.baeldung.com/linux/segmentation-fault-core-dumped Segmentation Faults and Fixing the Segmentation fault (core dumped) Error Last updated: January 11, 2024 Written by: Hiks Gerganov I temporarily unchecked "Block pop-up windows" in FireFox meanu -> Sttings -> Privacy & Security -> permissions down the window >> still got message #08********08 #] 01Feb2024 Extracting a Substring in Bash: ${VAR:start_index:length}, or $ cut -c 5-9 <<< '0123Linux9' +-----+ https://www.baeldung.com/linux/bash-substring Extracting a Substring in Bash Last updated: May 11, 2023 Written by: Kai Yuan 3.1. Using the cut Command We can extract from the Nth to the Mth character from the input string using the cut command: cut -c N-M. As we discussed in an earlier section, our requirement is to take the substring from index 4 through index 8. Here, when we talk about the index, it’s in Bash’s context, which means it’s a 0-based index. Therefore, if we want to solve the problem using the cut command, we need to add one to the beginning and ending index. Thus, the range will become 5-9. Now let’s see if the cut command can solve the problem: $ cut -c 5-9 <<< '0123Linux9' Linux As the output shows, we got the expected substring, “Linux“, so problem solved. In the example above, we passed the input string to the cut command via a here-string and saved an echo process. 3.3. Using Bash’s Substring Expansion We’ve seen how cut and awk can easily extract index-based substrings. Alternatively, Bash is sufficient to solve the problem, since it supports substring expansion via ${VAR:start_index:length}. Today, Bash is the default shell for many modern Linux distros. In other words, we can solve the problem without using any external command: $ STR="0123Linux9" $ echo ${STR:4:5} Linux As we can see in the output above, we solved the problem using pure Bash. #08********08 #] 11Sep2023 search "Linux and how do I get the length of a string?" +-----+ https://linuxhandbook.com/bash-string-length/ How to Find Length of String in Bash [Quick Tip] Here are various ways to calculate the length of a string in bash scripts. Abhishek Prakash Sep 1, 2021 • 2 min read Thankfully, getting length of string in bash is super simple. Let's say you have a string named my_string. Its length can be extracted as: ${#my_string} # enddoc