Hello, I am new. I looked around the forums but couldn't find anything specific with the problem i'm having.
Purpose: To translate all 'tabs' in the input to 'three spaces'.
Code:
Here is my script (so far):
#!/bin/sh
input=`echo $* | tr '\t' ' '`
echo "$input"
The problem I'm having: The translate utility seems to only replace the '\t' with the first character in the second string.
So let’s say I give the script this input:
{tab}hello
I want
hello
I get
hello
Other things I have tried
Code:
#!/bin/sh
input=`echo $* | tr '\t' '\ '`
echo "$input"
Code:
#!/bin/sh
input=`echo $* | tr '\t' '\ \ \ '`
echo "$input"
Code:
#!/bin/sh
input=`echo $* | tr '\t' '" "'`
echo "$input"
Nothing has worked so far, rather frustrating.
If you have read this far, you will most likely continue reading this, please do.
Thank you for taking your time to read this. Although you may find my script
to be amateur, I have just started in the world of unix/linux.If you have a solution
an explanation of why my script didn't work and an explanation of how the fixed version
works would be most helpful. I hope I didn't post in the wrong thread, my apologies.
thanks again.
Adam