TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

An introduction to data processing on the Linux command line

203 pointsby robertelderover 5 years ago

22 comments

tjlav5over 5 years ago
If you&#x27;re interested in this space, a great resource can be found at <a href="https:&#x2F;&#x2F;www.datascienceatthecommandline.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.datascienceatthecommandline.com&#x2F;</a> (a free guide to go along with an orielly book)
dima55over 5 years ago
A plug of my tools:<p>To visualize data coming in from a pipe, can pipe it to<p><a href="https:&#x2F;&#x2F;github.com&#x2F;dkogan&#x2F;feedgnuplot" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dkogan&#x2F;feedgnuplot</a><p>Very useful in conjunction with other tools to provide filtering and manipulation. For instance (the first one is mine):<p><a href="https:&#x2F;&#x2F;github.com&#x2F;dkogan&#x2F;vnlog" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dkogan&#x2F;vnlog</a><p><a href="https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;datamash&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;datamash&#x2F;</a><p><a href="https:&#x2F;&#x2F;csvkit.readthedocs.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;csvkit.readthedocs.io&#x2F;</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;johnkerl&#x2F;miller" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;johnkerl&#x2F;miller</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;eBay&#x2F;tsv-utils-dlang" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;eBay&#x2F;tsv-utils-dlang</a><p><a href="http:&#x2F;&#x2F;harelba.github.io&#x2F;q&#x2F;" rel="nofollow">http:&#x2F;&#x2F;harelba.github.io&#x2F;q&#x2F;</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;BatchLabs&#x2F;charlatan" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;BatchLabs&#x2F;charlatan</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;dinedal&#x2F;textql" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dinedal&#x2F;textql</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;BurntSushi&#x2F;xsv" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;BurntSushi&#x2F;xsv</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;dbohdan&#x2F;sqawk" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dbohdan&#x2F;sqawk</a><p><a href="https:&#x2F;&#x2F;stedolan.github.io&#x2F;jq&#x2F;" rel="nofollow">https:&#x2F;&#x2F;stedolan.github.io&#x2F;jq&#x2F;</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;benbernard&#x2F;RecordStream" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;benbernard&#x2F;RecordStream</a>
haddrover 5 years ago
Command Line tools are powerful beasts (e.g. awk) and they were always central to data preprocessing. But do we need to call it now a data science?
评论 #21613513 未加载
fizixerover 5 years ago
Regarding more than one mentions of UUOC in this thread:<p>- The original award started in 1995. Even though pentium was already out, I think it is safe to say that was the era of 486 PCs. In 2019, for day-to-day shell work (meaning no GBs of file-processing or anything like that), isn&#x27;t invoking UUOC and pointing out inefficiencies an example of premature optimization [1]?<p>- Isn&#x27;t readability a matter of subjectivity, and that for some folks &#x27;cat file&#x27; is more readable than &#x27;&lt;file&#x27; or a direct use of a processing command (like grep, tail, head, etc) [2] ? (The whole stackoverflow page is fairly illuminating [3]).<p>[1] <a href="http:&#x2F;&#x2F;wiki.c2.com&#x2F;?PrematureOptimization" rel="nofollow">http:&#x2F;&#x2F;wiki.c2.com&#x2F;?PrematureOptimization</a><p>[2] <a href="https:&#x2F;&#x2F;chat.stackoverflow.com&#x2F;rooms&#x2F;182573&#x2F;discussion-on-answer-by-jonathan-leffler-useless-use-of-cat" rel="nofollow">https:&#x2F;&#x2F;chat.stackoverflow.com&#x2F;rooms&#x2F;182573&#x2F;discussion-on-an...</a><p>[3] <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;11710552" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;11710552</a>
mark_l_watsonover 5 years ago
Not really where the author is heading, but I like to configure a backend for mathplot lib to render graphics in a terminal so when I am SSHed to a remote system I can get inlined plots.
评论 #21616621 未加载
评论 #21617811 未加载
ibernover 5 years ago
Here are some ways you could simplify some of the tasks in the article, saving on typing:<p><pre><code> cat data.csv | sed &#x27;s&#x2F;&quot;&#x2F;&#x2F;g&#x27; </code></pre> can be simplified by doing this instead:<p><pre><code> cat data.csv | tr d &#x27;&quot;&#x27; </code></pre> This awk command:<p><pre><code> cat sales.csv | awk -F&#x27;,&#x27; &#x27;{print $1}&#x27; | sort | uniq </code></pre> Can be replaced with a simpler (IMO) cut instead:<p><pre><code> cat sales.csv | cut -d , -f 1 | sort | uniq </code></pre> When using head or tail like this:<p><pre><code> head -n 3 </code></pre> You don&#x27;t need the -n:<p><pre><code> head -3 </code></pre> Also shout out to jq, xsv, and zsh (extended glob), all nice complements to the typical command line utils.
评论 #21616995 未加载
评论 #21616703 未加载
评论 #21617668 未加载
arminiusreturnsover 5 years ago
When I was at a genetics lab, I was helping some researchers on something and spent 3 days writing a perl script, which kept failing. I sent an email to one of the guys who wrote the paper the research was being based on, and he said, why not try awk like this? With a little work, I turned 3 days of perl into a 1 line awk that was faster than anything else for the job at the time. That was an inspirational moment for the fundamental power of the unix philosophy and the core utilities in linux for me.<p>Good introductory article here!
mjirvover 5 years ago
This is a great list and well-written. As a data professional, I use these commands all the time and my job would be much harder without them. I also learned a few new things here (`tee` and `comm`).<p>I was lucky that my first job was as a support engineer at a data-centric tech company, which is where I learned these. I&#x27;ve often thought about how to teach them to data analysts coming from a non-engineering background. This is comprehensive but clear and would be a perfect resource for training someone like that. Thank you!
fizixerover 5 years ago
I&#x27;ll just leave one of my past comments [1] here.<p>[1] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17324222" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17324222</a><p>P.S.: Not essential, but it really becomes a joy when, as a touch typist, I have turned on vi mode in the shell (e.g., with &#x27;set -o vi&#x27;). My fingers never have to leave the home row while I do my shell piping work from start to finish. (no mouse, no arrow keys, etc.)
评论 #21615744 未加载
pferdeover 5 years ago
Huh, so it turns out that I&#x27;ve been a &#x27;data scientist&#x27; for over 20 years. Who knew?
评论 #21614261 未加载
rodrigo975over 5 years ago
Why people use Linux in place of *nix ?<p>Even worst, most of the tools (cat, grep, awk) are Unix commands, redeveloped by the GNU project in most of the GNULinux distros.
评论 #21615597 未加载
评论 #21614631 未加载
评论 #21615548 未加载
评论 #21614721 未加载
wolfhumbleover 5 years ago
Very nice video, and I like the way you combine it with text and examples! :-) Looking forward to reading the other articles on your page as well!
hackerm0nkeyover 5 years ago
Very useful article. Learned a couple of new things here.<p>While reading the idea that I know most of this, would that made me a data scientist? Jumped at me.<p>But then I quickly recovered from that thought that surely knowing some of the tools someone could use for a certain domain does not make you expert at that domain.<p>Might just be the case of same ingredients, different recipes.
pedro84over 5 years ago
This is a little more awk-ish:<p>awk -F, &#x27;$2 == &quot;F&quot; {$0=(($1-32)*5&#x2F;9)&quot;,C&quot;} {print}&#x27;
评论 #21616716 未加载
pnutjamover 5 years ago
This is still useful information for data scientist who end up on Linux.
oburbover 5 years ago
This is also useful: <a href="https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;datamash&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;datamash&#x2F;</a>
mnaydinover 5 years ago
I wouldn&#x27;t use awk for simple things such as<p><pre><code> cat sales.csv | awk -F&#x27;,&#x27; &#x27;{print $1}&#x27; </code></pre> but I&#x27;d prefer<p><pre><code> cut -d, -f1 sales.csv</code></pre>
teddyhover 5 years ago
Useless use of cat detected!<p><i>Rememeber, nearly all cases where you have:</i><p><pre><code> cat file | some_command and its args ... </code></pre> <i>you can rewrite it as:</i><p><pre><code> &lt;file some_command and its args ... </code></pre> <i>and in some cases, such as this one, you can move the filename to the arglist as in:</i><p><pre><code> some_command and its args ... file </code></pre> — Randal L. Schwartz (<a href="http:&#x2F;&#x2F;porkmail.org&#x2F;era&#x2F;unix&#x2F;award.html#cat" rel="nofollow">http:&#x2F;&#x2F;porkmail.org&#x2F;era&#x2F;unix&#x2F;award.html#cat</a>)
评论 #21614655 未加载
评论 #21615699 未加载
lonelappdeover 5 years ago
Good intro to data <i>processing</i>.<p>tsort and comm were news to me.
c06nover 5 years ago
Can somebody explain the advantage of doing it on the command line vs in Python or R? What would a practical use case look like?
评论 #21614555 未加载
评论 #21615358 未加载
评论 #21614573 未加载
robertelderover 5 years ago
Hi, (I wrote the article). A few people commented noting that I included &quot;Data Science&quot; in the title, but the content doesn&#x27;t include any statistics or machine learning which is closer to the core definition of &#x27;data science&#x27;. I still think the title is appropriate since any kind of low-fidelity data science task you do on some had-hoc data (log files, heaps of text, web pages) is going to start with setting up a processing pipeline that involves these commands. I could have re-named it &quot;An intro to text processing&quot; or &quot;An intro to data processing&quot;, but then the people who need to see this content won&#x27;t associate the title with something they&#x27;re interested in, so they never benefit from it. The list of commands was chosen specifically with the question &quot;What Linux commands would someone answering data science&#x2F;business intelligence questions use?&quot; in mind. These commands are also among the list of ones that are usually already installed on every system.
评论 #21614648 未加载
评论 #21616089 未加载
评论 #21614801 未加载
评论 #21616519 未加载
评论 #21616203 未加载
netmonkover 5 years ago
Ugly UUOC (Useless Use Of Cat). Damn peoples, please i appreciate your will to share, but share good contents and stop spreading bad shell patterns....
评论 #21615876 未加载
评论 #21621759 未加载
评论 #21617182 未加载
评论 #21615031 未加载