commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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:
Takes a input file (count.txt) that looks like:
1
2
3
4
5
It will add/sum the first column of numbers.
There are 2 alternatives - vote for the best!
numsum is part of of the num-utils package, which is available in some Linux distros and can also be downloaded at http://suso.suso.org/xulu/Num-utils. It contains about 10 different programs for dealing with numbers from the command line.
Obviously you can do a lot of things that the num-utils programs do in awk, sed, bash, perl scripts, but num-utils are there so that you don't have to remember the syntax for more complex operations and can just think: compute the sum, average, boundary numbers, etc.
if you, like me, do not have the numsum, this way can do the same.
If you can do better, submit your command here.
You must be signed in to comment.
@unixmonkey2316 We love awk but save the cat's! :-)
< count.txt awk '{sum+=$1} END {print sum}'
Or:
printf '%s\n' $(( $(paste<infile -sd+) ))echo test | fold -w 1t
e
s
t
@myself: silly me, sorry for the noise, all wrong.
How about:
awk '{ sum+=$1} END {print sum}' count.txtAnother useless use of cat.
@rjc those who don't understand awk have redundancies all over the place. 'grep foo | awk', 'cat bar | awk', etc.
cat test.log | awk -F, '{sum+=$1} END{print sum}'
But my input file is
1,www.zzzzzzzzzzzzz/,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,bro.jpg&h=70&w=105&usg=AFrqEzeDZa4qbOTgz8UtMnCmRSVWz6Jccg","LG-KP500 Teleca/WAP2.0 MIDP-2.0/CLDC-1.1","","image/jpeg"
2,www.t.com
Iam getting error :
records number 1 has too many feilds...
Can you give me the solutions