Is it possible to give spaces using unix commands at a particular column?
eg:
123 56 89(input)
123 56 89(output)
Is it possible to give spaces using unix commands at a particular column?
eg:
123 56 89(input)
123 56 89(output)
i need two spaces between 3 and 5
Wrong subforum. Something like this?
echo "123 56 89(input)" | sed 's/ / /1'
123 56 89(input)
Next time the right forum, k?!
The input is not constant. It varies repeatedly.
I am going to transfer this thread to the "shell scripting" forum, as it belongs there.
If the input varies, as you say, you have to find a constant pattern to express it. If - for instance - the place where you want to insert a second space is the first place where a "3" and a "5" are separated by a blank then the expression to match this would be
sed 's/3 5/3 5/'
which would mean "search for the first occurrence of "3-space-5" and replace it with "3-space-space-5".
If, also for example, it is the space between the first two "words" in a line, than the expression would have to be:
sed 's/ / /'
This means: search for the first occurrence of "space" and replace it by "space-space". This way "xxx-space-xxx" would become "xxx-space-space-xxx" and "xxxxxx-space-xx" would become ""xxxxxx-space-space-xx".
And so on and so forth. get a book about regular expressions and it will teach you how to do that.
I hope this helps.
bakunin