Stripping @@@ in the data line

February 7, 2011 at 04:10:44
Specs: Linux x86_64
I have a data as follows...


I want to strip "@@@" and save it in another array without those "@@@" like ...

Model4 45-678 - 45/89 - - - -

I tried like this

dbarray=( $(echo ${l2} | tr "@@@" "\n") )

But problem is, tr command is striping even Email ID @ too, so it is printing as " jae"
Can anybody help to solve this issue.


See More: Stripping @@@ in the data line

February 7, 2011 at 09:22:56
You can use sed to replace only 3-@:



echo "$i2"|sed 's/@@@/ /g'

My question is: are you trying to place every element delimited by @@@ into a bash array?

Report •

February 7, 2011 at 12:12:22
I am going to assume you do to build a a bash array where every element in a string is delimited by @@@.

I have been thinking about this and I don't seem to be able to replace @@@ with a new-line. However, choose a character that is not used in the string (I know, that might be a severe limitation) and replace every @@@ with that character. I choose the pipe symbol, |



array_name=( $(echo "$i2"|sed 's/@@@/|/g'))
echo ${array_name[@]} # Model4 45-678 - 45/89 - - - -

Report •

February 7, 2011 at 22:06:56
Thanks for your replies.

Yes, I want to store in an array.

Your solution worked.

Report •
Related Solutions

Ask Question