Skip to content

--- tags: - Shellcategories: - Linuxdate:created: 2020-09-11# updated: 2024-01-19---

Shell string interception

Format illustrate
${string: start :length} Starting from the start character on the left side of the string string, intercept length to the right.
${string: start} Intercept from the start character on the left side of the string string until the end
${string: 0-start :length} Starting from the start character on the right side of the string string, intercept length to the right.
${string: 0-start} Intercept from the start character on the right side of the string string until the end
${string#*chars} Starting from the first occurrence of chars in the string string, intercept chars
${string##*chars} Starting from the last occurrence of chars in the string string, intercept chars
${string%*chars} Starting from the first occurrence of chars in the string string, intercept chars
${string%%*chars} Starting from the last occurrence of chars in the string string, intercept chars

REF[1]. Linux-A brief analysis of text processing commands

[2]. Cloudflare-DDNS-with-ShellScripts [3]. Auto-Archive-Files-with-ShellScripts