S
S
Sergey2015-08-23 21:07:04
linux
Sergey, 2015-08-23 21:07:04

How to remove a space from the beginning of a string in a bash variable?

There is a variable a=" 12345"
How to get a="12345" without a space at the beginning of the string?

b=${a/ //} #не срабатывает
b=${a:1} #тоже

What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2015-08-23
@butteff

$ a=" 12345"
$ echo "-${a:1}-"
-12345-
Why this option doesn't work for you, I don't understand - everything is OK
echo ${a// /}
12345
here just swap the arguments

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question