remove duplicated stringd in a line...
hi,
i have this code: Code:
$ echo "bubu gaga bubu dede" | awk '{ while(++i<=NF) printf (!a[$i]++) ? $i FS : ""; i=split("",a); print "" }' i.e.: Code:
$ echo "bubu gaga bubu-dede" | awk .... many thanks... |
Code:
awk 'BEGIN{FS = "[ -]"}{ while(++i<=NF) printf (!a[$i]++) ? $i " " : ""; i=split("",a); print "" }' |
many thanks colucix! it works great...
e anche il fatto che siamo entrambi di bologna credo sia una discreta coincidenza! :) |
He he! Bologna forever! ;)
|
btw,
if you don't mind, would you take a look at this thread, as well? http://www.linuxquestions.org/questi...ations-945160/ if you could help me, you'd surely increase your bonus to get a new battery for your laptop: removed :) |
Quote:
|
ops... :)
i guess corruption is when you try to let someone do something he shouldn't... but i can't see why you shouldn't help me with that problem... :) |
Quote:
|
Here is a slight revision if you like:
Code:
echo "bubu gaga bubu-dede" | awk '{ORS=RT}!_[$0]++' RS="[ -\n]" |
mmm...
Code:
$ echo "bubu gaga bubu-dede" | awk '{ORS=RT}!_[$0]++' RS="[ -\n]" |
It depends on the shell you're using. It works in bash. Anyway, since the problem happens outside the awk one-liner, put the RS definition inside it and the trick is done:
Code:
echo "bubu gaga bubu-dede" | awk 'BEGIN{RS="[ -\n]"}{ORS=RT}!_[$0]++' Code:
echo "bubu gaga bubu-dede" | awk '{ORS=RT}!_[$0]++' RS='[ -\n]' |
mmm...
Code:
$ echo "bubu gaga bubu-dede" | awk '{ORS=RT}!_[$0]++' RS='[ -\n]' |
Which version of awk are you running?
Code:
awk --version |
Code:
$ awk --version |
The same for me. At this point it might depend on the locale settings and the ambiguous interpretation of the dash - inside the character list. Your best bet is to move it at the beginning of the list:
Code:
echo "bubu gaga bubu-dede" | awk '{ORS=RT}!_[$0]++' RS='[-\n ]' |
All times are GMT -5. The time now is 01:26 AM. |