Answers for "bash cut string at whitespace"

2

bash strip preceeding white space

# Basic syntax:
sed 's/^ *//g'

# Example usage:
echo '                    text' # Printing without sed command
-->                     text
echo '                    text' | sed 's/^ *//g' # Pipe to sed command
--> text
Posted by: Guest on September-28-2020
0

how to remove every space in a string in bash

#!/bin/bash

#Make our variable
var="foo bar"

#Print it without the spaces
echo ${var//[[:blank:]]/}

#Output will be foobar
Posted by: Guest on October-17-2020

Code answers related to "bash cut string at whitespace"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language