How to echo a string with multiple spaces in shell?

How to echo a string with multiple spaces in shell?

The default value of $IFS contains the TAB character, so in echo -e $MYCUSTOMTAB”blah blah”, $MYCUSTOMTAB is just split into nothing so it becomes the same as if you had written: (you probably don’t want -e here btw). Or if you want printf to do the same kind of , expansions that echo -e does, use %b instead of %s:

How to ignore the space in between words in Bash?

If you just want to ignore all the space in between you can use echo your text |tr -d [ [:space:]]| grep “yourtext” but the output will not have any space.

How to match words and ignore multiple spaces?

Something like the following will help you get what you need: It takes the input and makes it lower case then searches for matches that are lower case. We use \\s* for 0 or more whitespace (so will include tabs etc.) and \\s+ for 1 or more whitespace.

Is there a space in the second string?

The first four characters of the second string ( “abcd”) are all ignorable, so the second string can be compared to the first string beginning with the space.

Is there way to pass a string with spaces as a function argument in Bash?

However, what’s actually output is: Is there a way to pass a string with spaces as a single argument to a function in bash? you should put quotes and also, your function declaration is wrong. And like the others, it works for me as well. Tell us what version of shell you are using.

How to delimit whitespace in a string in Bash?

The solution was to change the call to the function in explicit argument handling from the ‘main’ towards the function : the call would then be myFunction “$1” “$2” “$3” which will preserve the whitespace inside strings as the quotes will delimit the arguments

Can a string be set into a string?

You could have an extension of this problem in case of your initial text was set into a string type variable, for example: In this case if you don’t pass the status_message variable forward as string (surrounded by “”) it will be split in a mount of different arguments.