[{"data":1,"prerenderedAt":114},["ShallowReactive",2],{"/2025/12/24-unwanted-dollar-sign-in-bash-script":3},{"id":4,"title":5,"body":6,"date":105,"description":49,"extension":106,"meta":107,"navigation":108,"path":109,"robots":110,"seo":111,"stem":112,"__hash__":113},"posts/2025/12/24 unwanted-dollar-sign-in-Bash-script.md","24 Unwanted Dollar Sign In Bash Script",{"type":7,"value":8,"toc":102},"minimark",[9,18,25,28,31,33,36,50,52,55,63,65,68,76,78,89,91,94],[10,11,13],"post-title",{":date":12},"date",[14,15,17],"h1",{"id":16},"unwanted-dollar-sign-in-bash-script","Unwanted Dollar Sign in Bash Script",[19,20,21],"notes",{},[22,23,24],"p",{},"This is a repost from my old blog. First posted in 9/18/2020.",[26,27],"br",{},[22,29,30],{},"The script that I used ran fine for various flavors of Linux for a long time. But somehow, it produced unwanted dollar sign on Ubuntu 18.04, so my hours of troubleshooting starts.",[26,32],{},[22,34,35],{},"The simplest one I can say is I use echo with tab and variables and piped that to awk through AWS Systems Manager. It is similar to the following:",[37,38,39],"code-block",{},[40,41,46],"pre",{"className":42,"code":44,"language":45},[43],"language-text","v='variable'\nTAB=$'\\t'\necho \"${v}${TAB}\" | awk '{print $0}'\n","text",[47,48,44],"code",{"__ignoreMap":49},"",[26,51],{},[22,53,54],{},"In many flavors of Linux other than Ubuntu 18.04, even in Ubuntu 16.04, it produced the expected result:",[37,56,57],{},[40,58,61],{"className":59,"code":60,"language":45},[43],"variable\n",[47,62,60],{"__ignoreMap":49},[26,64],{},[22,66,67],{},"However, in Ubuntu 18.04, it ends the result with an extra dollar sign:",[37,69,70],{},[40,71,74],{"className":72,"code":73,"language":45},[43],"variable$\n",[47,75,73],{"__ignoreMap":49},[26,77],{},[22,79,80,81,88],{},"At first, I thought it marks end of line or the typical ",[47,82,87],{"className":83},[84,85,86],"bg-gray-200","p-2","rounded","\\0 (NUL character)"," that marks end of string, so I tried various ways to remove it such as using tr, gsub, etc. But none of them works.",[26,90],{},[22,92,93],{},"Eventually, I found out that the dollar sign comes from the TAB variable. To solve it, I have to replace the above with:",[37,95,96],{},[40,97,100],{"className":98,"code":99,"language":45},[43],"echo -e \"${v}\\t\"\n",[47,101,99],{"__ignoreMap":49},{"title":49,"searchDepth":103,"depth":103,"links":104},2,[],"2025-12-24T00:00:00.000Z","md",{},true,"/2025/12/24-unwanted-dollar-sign-in-bash-script",null,{"title":5,"description":49},"2025/12/24 unwanted-dollar-sign-in-Bash-script","wa436zzFPWRvd_dMg05OJwS83FtsfaoP68UveO4eoeE",1785167452083]