user430830
user430830

Reputation:

Remove quotes with SED

I am tracking some keywords on Twitter using the command below. I want to print just the "screen_name" property of the tweet author. I could get the command below working but want to remove "quotes" from the author screen_name. How could I do this?

curl -N -d @tracking http://stream.twitter.com/1/statuses/filter.json \
     -umyuser:mypass | \
sed -e 's/[{}]/''/g' | \
awk -v RS=',"' -F: '/^screen_name/ {print $2}'

Upvotes: 36

Views: 79054

Answers (4)

Joe Jobs
Joe Jobs

Reputation: 251

cat a.txt | tr -d "\042"

It is better because it works in Windows too (using gnuwin32)

Upvotes: 0

deadkarma
deadkarma

Reputation: 3144

A little late to the party, this this utility sounds like it can be useful for parsing the json twitter returns: http://stedolan.github.io/jq/

Upvotes: 1

sorpigal
sorpigal

Reputation: 26116

Why use sed?

| tr -d '"'

Right tool for the right job.

Upvotes: 147

codaddict
codaddict

Reputation: 455440

You can do:

...existing_commands | sed 's/"//g'

Upvotes: 12

Related Questions