65 Comments
- BobbyOnions, on 10/12/2007, -0/+7This is lame. Most of those commands can be condensed even further.
"ps -ef | grep | awk" - *****, this is "killall"
"date | awk" - read the man page for "date", the options are already there to format the output.
etc. etc. - res0nat0r, on 10/12/2007, -0/+5the writer of this article must have too much time on his hands..all of these tips are over complicating simple matters...
- dongiaconia, on 10/12/2007, -2/+6A GUI, a Command Shell and a Daemon walk into a bar...
- axcess99, on 10/12/2007, -0/+3why
date | awk -F : '{ print $1 ":" $2 }' | awk '{ print $1 " " $2 " " $3 }'
when you can
date +"%a %b %d"
apparently these experts can't use man pages - mackstann, on 10/12/2007, -0/+2Also for example, ls -1 is redundant when piping to another command. ls detects that the output is not a terminal and will automatically format its output as one column. This is pretty lame, and I wouldn't even call myself a veteran.
- aut0maticdan, on 10/12/2007, -0/+1errr... making a lot of this a bit too complicated
date +%a" "%b" "%e
killall -9 ppp
if -F is your favorite flagg for awk, just use cut
not a bad demonstration of how pipes work, but these aren't the best one liners I've seen.
Especially the most veteran Linux users will not learn something.
daniel - blah12345, on 10/12/2007, -0/+1I don't know what you guys are talking about. I found this article very useful...for example, I now use the following line to edit my motd file:
if [ $(date | awk '{print $3}') -gt 0 ];then beamer=0;case $beamer in 1) ls -1a | grep -Ev ".|.." ;; 2) cat /etc/motd ;; 0) [ -d /usr/bin ] && vi /etc/motd ;; *) whatis "I'm super cool because I can use ;'s a lot!" | grep -iv "nothing appropriate";;esac;else find / -type f -size +100k -ls -exec echo {} ; ;fi - archer99, on 10/12/2007, -2/+3The best Linux One Liner:
unzip; strip; touch; finger; mount; fsck; more; yes; umount; sleep - nofxjunkee, on 10/12/2007, -0/+1how on earth did this get to the front of digg? i've only been using linux for a few years myself (nowhere near veteran) and i learned nothing. pipes are unix 101 material.
- volz0r, on 10/12/2007, -1/+2Laugh. Who the hell posted that *****? How are these the 'Best Linux One Liners'?
It looks like a guy who absolutely no clue toying around trying to figure things out
while somehow being impressed with himself. No 'veteran' is going to look at that
site and see anything but a newbie posting pretty basic stuff. - thotpoizn, on 10/12/2007, -0/+0Dugg - just for the pissing and moaning in the comments! :)
- jerrygofixit, on 10/12/2007, -0/+0@jeznav
wish someone would get into that site and put that line in first just to see how many people would actually do it and complain to him, but of course, you'd have to use about 20 more pipes for it to look authentic. - Slackwise, on 10/12/2007, -0/+0How does ***** like this get to the front page? Honestly...
- diecastbeatdown, on 10/12/2007, -0/+0this was a waste of my time. mentor, you forgot to put the filename after the awk.
0troy's:
cat /var/log/secure|awk '/Failed password/ {print $13}'|cut -b 8-|sort|uniq -c|sort -nr
just one quick thing that will make it short is that you don't need to feed awk with cat unless you are performing another function ebfore the awk. awk can implement it's commands onto a file named. so:
awk '/Failed password/ {print $13}' /var/log/secure|cut -b 8-|sort|uniq -c|sort -nr
If you paste a matching line of your input before the commands are executed and after then i can see what you are looking to get from what you have and offer a shorter alternative. for all i know you are talking about a vpn syslog.
very useful awk one-liners:
echo -e "oknok" | awk '! a[$0]++' (removes duplicate lines)
echo "yo totally cool" | awk '{gsub(/totally/,"not";print}' (find and replace all instances of given text)
but if awk is considered a 'linux' one-liner, then so should perl, python and any other compilable scripting language. - spxiii, on 10/12/2007, -0/+0I love fscking my system.
fsck.cramfs - mentor, on 10/12/2007, -0/+0awk '/Failed password/ {c[$13]++}END{for (u in c)print c[u], u}' | sort -nr
- 0Troy, on 10/12/2007, -0/+0cat /var/log/secure|awk '/Failed password/ {print $13}'|cut -b 8-|sort|uniq -c|sort -nr
Prints a list of your top offenders.
(ps: neat freak, so comment if you can shorten it ^_^) - michaelstone, on 10/12/2007, -0/+0I actually thought they'd be jokes. Boy, was I pissed. Label your ***** better, man.
- otomo, on 10/12/2007, -0/+0$ date | awk -F : '{ print $1 ":" $2 }' | awk '{ print $1 " " $2 " " $3 }'
That dude needs to run this great one liner:
man date
Why the hell anyone would use awk to parse dates' output is beyond me. This guy is obviously not a veteran of a unix.
Here, my contribution on how to do it the "right" way. (more right at least)
$ date +"%a %b %e"
Much simpler. - cozby, on 10/12/2007, -0/+0That was bloody terrible. So bad in fact that I had to register just to post this comment - and I HATE registering, but not as much as I hated this article.
... and I thought /. was bad.... - digdugdig, on 10/12/2007, -0/+0dugg, because this article make all the real linux veterans cry... :D
- akilleen, on 10/12/2007, -0/+0Awesome! Here is my one-liner to add....
ls -l | cat | xargs -I {} echo {}
it wouldn't hurt to pipe it through xargs a few more times, so we can use as many processes as possible. - SenyorDrew, on 10/12/2007, -2/+2not sure what veteran linux users you've been hanging around ...
- riczho, on 10/12/2007, -0/+0Wow.. this is horrible-- I wouldn't consider myself a veteran, but even I know that most of these are completely overcomplicated. Some simpler equivalents:
date +"%a %b %d" (Thanks to "man date")
ping -w2 host | grep % (this is more than enough)
killall ppp (or kill `pgrep ppp`)
ls | wc -l - brian223, on 10/12/2007, -0/+0> why
> date | awk -F : '{ print $1 ":" $2 }' | awk '{ print $1 " " $2 " " $3 }'
> when you can
> date +"%a %b %d"
why ..
date +"%a %b %d"
when you can,
date | perl -ne 'print "$1" . "n" if /^(.*)sd+:.*/'
:-P - Slayback, on 10/12/2007, -0/+0BrewmasterC, that's a perfect example of why you partition your *nix boxen. Too many people just do one huge partition now adays, and then their box crashes when some particularly noisy apps starts logging like crazy, when /var could have been the extent of the impact.
- draj, on 10/12/2007, -0/+0Unbelivable that this makes it to the front page. Don't digg the headline. Digg the article, please.
- sudonim, on 10/12/2007, -1/+1What is black, white, and red all over?
Answer:
A Penguin wearing a red hat. - riczho, on 10/12/2007, -0/+0Oops.. replace kill `pgrep ppp` with pkill ppp in my previous comment.
- perral1, on 10/12/2007, -0/+0"they forgot the best one...
:(){ :|:& };:"
I guess this is why you don't type random things off the Internet into a console? *shoots self for being a n00b*
BTW i don't recommend typing that into anything resembling bash...*twitch...flashbacks to BSODs...twitch*....
anyone know where i can find a user quota tutorial?
:P
-Perral1 - mentor, on 10/12/2007, -0/+0Well, given that you can probably run most of these on other UNIces with minor or no modification...
- mentor, on 10/12/2007, -0/+0Everyone else has said it; but this is nowhere near veteran or wizadry level.
On another topic, I was trying to replace all the newlines in a string with something else, in sed (There may be better tools; I am just interested/examining sed). The best I could come up with was ':s;N;$!bs; s/n//g;p'. It's the first part that important. - juicewvu, on 10/12/2007, -0/+0this is horrible, most of this stuff can be done in a much eaiser way.
- burke, on 10/12/2007, -0/+0I guess I learned a tiny little but about awk... I definitely need to figure out how to use it now. Other than that, I agree, this is rather pointless.
- brian223, on 10/12/2007, -0/+0oh, retarded. digg removes backslashes..
- capajc, on 10/12/2007, -0/+0If the most veteran linux user would learn something from a web list of commands, what does that say about the knowledge level of veteran linux users? Shouldn't they know this stuff already?
Perhaps the poster was exaggerating.
And the one-liners in that article were _not_ funny, either. - BrewmasterC, on 10/12/2007, -0/+0yes | write "Don't you hate dial-up connections?" username &
Just make sure your body isn't piping standard output/err to a file. A guy I know did and the sys-admin wasn't to happy when the DEC alpha box crashed with "Whassup?Whassup?Wha..." over almost the entire hard drive. - MurrayFox, on 10/12/2007, -2/+1s/best/worst/
- jpyun, on 10/12/2007, -1/+0Accidentally dugg.
- 0Troy, on 10/12/2007, -1/+0Actually I mean:
digg|cat|ps|ls -1|pineapple|cat - filez|more|less|woot > /dev/null; ./undigg
(hey it's an overly complicated, utterly useless one-liner! digg me!) :-P - abece, on 10/12/2007, -2/+1command line hell.. use macos x
- draj, on 10/12/2007, -2/+1I can not.
- 0Troy, on 10/12/2007, -1/+0@jpyun, to undigg, click on your name, and find where it lists this article as "dugg" and click "undigg"
- gerkin, on 10/12/2007, -1/+0lame no digg. you need to hang around some "linux vetran" users a bit more methinks LOL. RTFM, it helps, really.
- inactive, on 10/12/2007, -1/+0"not sure what veteran linux users you've been hanging around ..."
so true - aarslank, on 10/12/2007, -1/+0No digg. Not even worth a comment. Why am I here...
- 0Troy, on 10/12/2007, -1/+0Erm... best?
Ahh, hell. I'll digg it anyways just because it's not political... - sdm011, on 10/12/2007, -1/+0Am I the only person here who clicked this link expecing linux jokes?
- zetsurin, on 10/12/2007, -1/+0> shutdown now
- carlosreif, on 10/12/2007, -2/+1no digg.
-
Show 51 - 64 of 64 discussions



What is Digg?
The Digg Toolbar for Firefox lets you Digg, submit content, and keep track of Digg even when you're not on the Digg site. Download the official