sample.csv: 79.36,94.93,10.92,27.33,95.90 3.57, 20.80,67.06,2.16, 79.23 48.45,27.95,7.66, 56.71,59.97 69.02,89.59,33.88,42.73,22.60 10.15,44.86,70.86,98.45,22.23 Show Sample Output
Inspired by Tatsh's comment.
Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?
You must be signed in to comment.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
sed -e 's/\(\s\+\)\?,\(\s\+\)\?/+/g' < file.csv | bc
If you have GNU sed, you can use -r to make this much easier to read:sed -r -e 's/(\s+)?,(\s+)?/+/g' < file.csv | bc
Yes, this works for floating point too. file.csv: 1,2,3,4,5.5 7,2,3.6666,5,10 Output:15.5
27.6666
1,2,3,4,5
becomes1,14
. @tatsh: Your command just sums the rows, it doesn't match the original command. . @tatsh: I disagree with your comment about perl. OK, it's a bit high-level, but I'm always keen to see as many possible alternatives for these "computational" types of commands. Personally, I too would reach for sed or awk first.perl -e 'for($t=0;;$t++){print chr +($t*($t^$t+($t>>15|1)^($t-1280^$t)>>10))%256}' | play -t s8 -v 0.25 -
(play is a symlink to sox; it needs to be invoked that way, this should come with your installation of sox) Yes this could be (very similarly) done in awk but few could read it in one line very easily by comparison.