TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How would you improve this bash oneliner for deleting tweets?

32 点作者 jamiehall大约 5 年前
Many people use tweet deletion services, which periodically remove everything from their Twitter timeline; I wondered if it could be done from a Bash command line.<p>I wrote up my experiences as an explainer for nontechnical people: <a href="https:&#x2F;&#x2F;jamiehall.cc&#x2F;2020&#x2F;03&#x2F;10&#x2F;delete-all-your-tweets-with-one-line-of-bash&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jamiehall.cc&#x2F;2020&#x2F;03&#x2F;10&#x2F;delete-all-your-tweets-with-...</a><p>TL;DR, here is the oneliner I&#x27;ve been using:<p><pre><code> $ twurl &quot;&#x2F;1.1&#x2F;statuses&#x2F;user_timeline.json?screen_name=YOUR_TWITTER_HANDLE&amp;count=200 &amp;max_id=$( twurl &#x27;&#x2F;1.1&#x2F;statuses&#x2F;user_timeline.json?screen_name=YOUR_TWITTER_HANDLE&amp;count=200&amp;include_rts=1&#x27; | jq -c -r &#x27;.[] | .id_str&#x27; | head -10 | tail -1) &amp;include_rts=1&quot; | jq -c -r &#x27;.[] | .id_str&#x27; | parallel -j 10 -a - twurl -X POST &#x2F;1.1&#x2F;statuses&#x2F;destroy&#x2F;{1}.json &gt; &#x2F;dev&#x2F;null </code></pre> [Edit: I&#x27;ve put line breaks in there to make it more legible.]<p>I&#x27;m curious if it&#x27;s possible to do better. In particular: could this be more elegant? Is it possible to do it using common built-ins, instead of twurl and jq?<p>Any suggestions or improvements would be very welcome!

12 条评论

rhacker大约 5 年前
I feel like this is normally the content you see in Stack Overflow
评论 #22690466 未加载
toomuchtodo大约 5 年前
You might consider putting this in a GitHub Gist, sharing the link for it, and accept comments and improvements within the Gist comments functionality.<p>This would also allow others to fork your code to improve upon or keep a copy for themselves.
评论 #22690042 未加载
评论 #22690180 未加载
Pirate-of-SV大约 5 年前
<p><pre><code> jq -c -r &#x27;.[] | .id_str&#x27; # Can be rewritten to jq -r &#x27;.[].id_str&#x27; jq -c -r &#x27;.[] | .id_str&#x27; | head -10 | tail -1 # Can be rewritten to jq -r &#x27;.[9].id_str&#x27;</code></pre>
评论 #22697335 未加载
t0astbread大约 5 年前
What are the rate limits on the &#x2F;statuses&#x2F;destroy endpoint? I&#x27;ve checked the docs and the docs say it is limited but the actual limit is not specified.<p>Other than that, thanks for writing this! I&#x27;ve been thinking about a tool like this and this might come in handy. The code looks fine to me although I would probably spin this out into a script and add some logging, as others have already pointed out.
viraptor大约 5 年前
I don&#x27;t think there&#x27;s a good reason to calculate the max_id every time. If you want to delete all tweets, you could skip it.
a-wu大约 5 年前
I&#x27;ve tried this before in a Python script but quickly got rate limited by the 300 tweet update limit [0]. Does this get around that?<p>[0] <a href="https:&#x2F;&#x2F;developer.twitter.com&#x2F;en&#x2F;docs&#x2F;basics&#x2F;rate-limits" rel="nofollow">https:&#x2F;&#x2F;developer.twitter.com&#x2F;en&#x2F;docs&#x2F;basics&#x2F;rate-limits</a>
评论 #22690605 未加载
jamiehall大约 5 年前
Thank you to everybody who commented! The suggestions to use something more sensible than a oneliner (and to post on Stack instead) are well taken. A big motivation of this project was &quot;just because&quot;, for shits and giggles, so I hope it&#x27;s amused you for a minute or two. Cheers!
jlelse大约 5 年前
Not answering your question, but I found a way to mass delete tweets without creating an app: <a href="https:&#x2F;&#x2F;jlelse.blog&#x2F;posts&#x2F;mass-delete-tweets&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jlelse.blog&#x2F;posts&#x2F;mass-delete-tweets&#x2F;</a>
mirimir大约 5 年前
Not a Twitter user here, but would this delete retweets by others of your tweets?<p>Those might include tweets that you&#x27;d most want to delete. As well as ones that you&#x27;d most want to retain, for that matter.
评论 #22690039 未加载
ksherlock大约 5 年前
You could improve it by not tweeting in the first place.
cosmiccatnap大约 5 年前
Make it delete the account instead.
staktrace大约 5 年前
You could improve it by making it not a one-liner! Usually making it a multiple-liner can improve readability. And unless you&#x27;re typing it into the command line directly everytime you run it (as opposed to putting it in a file that you invoke) it doesn&#x27;t really matter how many lines it has.
评论 #22690623 未加载
评论 #22690595 未加载