我正在编写一个bash脚本,它将一些数据转换为变量,然后我需要格式化变量。它以下列方式保留一些文本:
“sth 23 asd 2435 jasbd null asdj 123 jasd j123 asd 24 null asd 436 123jwba null“
我想在每个null之后添加一个换行符。我该怎么做? 我的代码如下所示:
output=$(curl -s 'http://127.0.0.1:3000/api/com.pokemon.go/nearby?latitude='"$latitude1"'&longitude='"$longitude1"'&altitude=0step=10&offset=0' \
-H 'Authorization: Bearer '"$acces_token")
#bunch of formatting that works
output="${output//[}"
output="${output//]}"
output="${output//pokemons}"
output="${output//pokestops}"
output="${output//gyms}"
output="${output//gym_points}"
output="${output//{}"
output="${output//\}}"
output="${output//\"}"
output="${output//unsigned:false}"
output="${output//unsigned:true}"
output="${output//unsigned:null}"
output=${output//:/ }
output=${output//,/ }
#formatting that doesn't work
output="${output//null/null$'\n'}"
echo $output
但它不起作用