Hi...
i need a script to remove the space before and after the operator like( +, -, ||, &&).
Ex :
Input file
apple + manago
mango && fresh + apple fresh || fruit
Desired output:
apple+manago
mango&&fresh+apple fresh||fruit
Note: betwee the desired operator space should be removed, between words do not remove space.
Thanks in advance,
Vasanth
Try to build something like this...
echo "mango && fresh + apple fresh || fruit" | sed 's/\(.*\)\( && \)\(.*\)\( + \)\(.*\)\( || \)\(.*
\)/\1\&\&\3+\5||\7/'
Dear rakeshawasthi ,
i have a big file containing different names, and the operators(+,&&. -. ||) not in the a proper order. Kindly concern about the spaces near to the operators only.
And input is a file....
Thanks in advance...
Vasanth
Bump: Thanks in advance
vasanth
Bump: Thanks in advance
vasanth
panyam
June 17, 2009, 4:55am
4
sed -e 's/[ ]*+[ ]*/+/g' -e 's/[ ]*||[ ]*/||/g' -e 's/[ ]*\&\&[ ]*/\&\&/g' -e 's/[ ]*-[ ]*/-/g' input_file.txt
Ohh, I think my hint was good enuf for you to start with...anyways,
cat inputfile | sed 's/[ ]+[ ]/+/g' | sed 's/[ ]||[ ]/||/g' | sed 's/[ ]&&[ ]/\&\&/g'
Thanks rakeshawasthi,
urs too working fine..
Thanks:b:
vasanth
-----Post Update-----
Dear panyam / rakeshawasthi ,
In the above case everything fine, but if i want to remove the spaces before and after / operator, what i need to do add in sed...
-----Post Update-----
Dear panyam / rakeshawasthi ,
In the above case everything fine, but if i want to remove the spaces before and after / operator, what i need to do add in sed...
-----Post Update-----
Thanks in advance
vasanth
-----Post Update-----
Advance thanks