SAP/메모장

shell script 에서 Text Trim 처리

그녀는애교쟁이 2023. 1. 2. 18:32
반응형

 

 

 

 

 

echo "   lol  " | xargs
echo "  this string has a lot       of spaces " | xargs echo -n

Produces: 'this string has a lot of spaces'

 

https://stackoverflow.com/questions/369758/how-to-trim-whitespace-from-a-bash-variable

 

How to trim whitespace from a Bash variable?

I have a shell script with this code: var=`hg st -R "$path"` if [ -n "$var" ]; then echo $var fi But the conditional code always executes, because hg st always prints at least one newline cha...

stackoverflow.com

 

shell script 너무 어려운 것.. 텍스트에서 앞뒤 공백 트림 처리를 할 때 이렇게 처리하면 잘 동작한다.

 

 

 

 

 

'SAP > 메모장' 카테고리의 다른 글

sftp 기본 포트(22) 에서 다른 포트 변경  (0) 2022.12.12