Slashdot Mirror


What's Your Command Line Judo?

lousyd asks: "We all have our CLI amor. That two- or three-letter command that fiddles our heartstrings. 'mv' is pedestrian, but 'mmv' is so cool. 'cp' can lug bits around all day to no applause, but 'cpio' will excite even the most jaded of command line linguists. 'How perfect!' you exclaim. So what's your poison? What turns you on? What little known command performs just the right function for you?"

272 comments

  1. hrm. by grub · · Score: 2, Funny


    foad works every time.

    --
    Trolling is a art,
    1. Re:hrm. by poopdeville · · Score: 1

      I was kind of hoping there was a fuck off and die command. Imagine my disappointment when man foad returned "No manual entry for foad." :-(

      --
      After all, I am strangely colored.
  2. lh and hog by newsblaze · · Score: 4, Informative

    My favourites are

    lh ls -lt !* | head -15

    which shows me the newest 15 stories in the current or specified directory

    hog "ps -eo pcpu,vsz,args,time | sort -rn | head -11"

    which shown the 10 most cpu-intensive processes

    --
    Daily News http://newsblaze.com
  3. can't eat just one by yagu · · Score: 5, Informative

    Command line judo? Sheesh! Where to start?

    Okay, the tool I'm using now: vim, derivative of Bill Joy's vi, with color syntax and a bounty of enhancements. (Yes, I prepare my comments in vi, then cut and paste, don't even try to make me use some GUI text widget editor and claim it can be productive.)

    And then there's:

    • sed, or even ed. ed is great for scripting edit changes if you don't have the heart to master sed. I once used "sed" to create nroff output of document versions with delete markers (asterisks), change markers, and insertion markers from our technical documentation library.
    • awk. I couldn't have done half the work I've done in my career without this one. I watched entire teams scramble to solve some problem in Visual Studio, and would crank out a twenty line awk script that afternoon. Problem solved.
    • [ef]grep. If you're going to pipeline some shit, it's nice to filter it first (and sometimes second, then third, etc....). The grep family is second to none for this. (Funny story: I once worked at Microsoft. Was doing some stuff in DOS. Asked what command I'd use to find a string in a file or files. They showed me "FIND". Okay. I typed in:
      find mystring *.*
      and literally got back:
      mystring found in *.*, and then a listing of all the lines found. No reference to the files they were in... Shit, after all, I asked to find the lines in '*.*'.

      I complained. They showed me their (Microsoft's purchased from IBM) unix, "xenix", and their "grep" command. Ahhhhh, better. I typed: grep -i mystring *.*
      and it replied "unknown option -i". I complained about not having an "ignore case" option. They looked at me like I was crazy... "Why would you ever want to ignore case?"

    • diff. A life saver. 'Nuff said.
    • find. Freak! When I first met this command I said "go away!". Talk about an obtuse syntax and paradigm. Learn it! It's worth it.
    • xargs. Nice way to get around the line length restrictions of some of the unix shells.
    • zsh, bash, (but not csh)... Any interactive shell with a good history and command line completion mechanism. I never have to remember command syntax anymore... usually I can find a usable and editable example somewhere in the last 2000 commands I've executed.

    I could go on, and probably will in some subsequent posts. When you have so many well written, well evolved, well crafted, and well behaved tools all flying in

    1. Re:can't eat just one by Anonymous Coward · · Score: 1, Funny

      I complained. They [Microsoft] showed me their (Microsoft's purchased from IBM) unix, "xenix", and their "grep" command. Ahhhhh, better. I typed: grep -i mystring *.* and it replied "unknown option -i". I complained about not having an "ignore case" option. They looked at me like I was crazy... "Why would you ever want to ignore case?"

      ARG! Microsoft asked why you'd ever want to ignore case!? Do they even know about FAT and NTFS?

      Which, by the way, also explains your first anecdote. In Windows land, it's the filesystem driver that interprets the globs, not the shell. Enjoy your Saturday night, thinking about a filesystem driver interpreting wildcards.

    2. Re:can't eat just one by PunkOfLinux · · Score: 1

      I would like to think that they know about ntfs... aren't they the ones who created it?

    3. Re:can't eat just one by Anonymous Coward · · Score: 0
      In Windows land, it's the filesystem driver that interprets the globs

      Of this I am well aware... "glob.exe" is a command you'd better have in your command path when you're using MKS Toolkit (This was a very long time ago).

    4. Re:can't eat just one by Anonymous Coward · · Score: 0

      Yes, xargs is useful every now and then for handling piped results sanely.

      For shells, bash > tcsh > csh. I'm really pleased that bash allows me to do more than (t)csh does.

    5. Re:can't eat just one by ATomkins · · Score: 2, Informative
      I complained. They [Microsoft] showed me their (Microsoft's purchased from IBM) unix, "xenix"...

      Sorry to be picky, but Microsoft bought a license for UNIX from AT&T, developed Xenix, then sold it to SCO who would transform it into SCO UNIX.

    6. Re:can't eat just one by bergeron76 · · Score: 2, Interesting

      I actually use a shell script in my .bash_logout that appends my .history file to a master "history" file. It's helped me numerous times when I've need to recall a command I ran ages ago. I just use grep succesively until I find the obscure command string.

      I don't mean that I was looking for a single command; I use bash pretty hardcore, and I've used pipes to do some pretty extensive things - that's where I think history has it's greatest use.

      (and yes, I'm using bash 3 and my HISTSIZE envvar is set to 10000)

      --
      Don't think that a small group of dedicated individuals can't change the world. It's the only thing that ever has.
    7. Re:can't eat just one by Dadoo · · Score: 1

      xargs

      Sorry, have to disagree with you on this one, or rather, have to rant that the need for this command is possibly the dumbest thing Unix has to offer. "Let's do globbing in the shell and, to make things even more difficult, let's give the command line a finite (and small) length." Don't get me wrong, I love Unix, but it's not perfect, but globbing in the shell/small command line/xargs is on my top 10 list of pet peeves.

      How would I have done it? Use a pipe! Possibly one of Unix's most important contributions to the OS world and it gets wasted...

      --
      Sit, Ubuntu, sit. Good dog.
    8. Re:can't eat just one by Matt+Perry · · Score: 1

      I use xargs all the time and not to get around shell line length restrictions.

      --
      Slashdot: Failed Car Analogies. Amateur Lawyering. Anecdote Battles.
    9. Re:can't eat just one by golgotha007 · · Score: 1

      I find xargs very useful.

      If I want to remove every nautilus RPM in my system, what easier way then:

      rpm -qa | grep nautilus | xargs rpm -e

    10. Re:can't eat just one by smallfries · · Score: 1

      [Ww][Hh][Yy] [Ww][Oo][Uu][Ll][Dd] [Yy][Oo][Uu]\?

      Life is so long...

      --
      Slashdot: where don knuth is an idiot because he cant grasp the awesome power of php
    11. Re:can't eat just one by Anonymous Coward · · Score: 0

      ibm did.

    12. Re:can't eat just one by vivek7006 · · Score: 1

      Could you please share that script?

      Thanxs

    13. Re:can't eat just one by cortana · · Score: 1

      >> In Windows land, it's the filesystem driver that interprets the
      >> globs, not the shell.

      WHAAAAAAAAAAT

      !

    14. Re:can't eat just one by Guy+Harris · · Score: 1
      ibm did.

      Could you please cite the evidence that leads you to believe that IBM created NTFS? (And if he really meant "HPFS", the same question could be asked.)

    15. Re:can't eat just one by lilmouse · · Score: 1
      Command line judo? Sheesh! Where to start?

      vi

      --LWM
    16. Re:can't eat just one by prefect42 · · Score: 1

      For most things there's another way around it though that avoids substrings. The previous:

      rm -f $(find . -name "*.o")

      could have been reworded as

      find . -name "*.o" -exec rm -f {} \;

      rm does get called a little excessively I'll concede... ;)

      As for that rpm -e $(rpm -qa | grep nautilus)

      --

      jh

    17. Re:can't eat just one by prefect42 · · Score: 1

      Although it'd be even neater as:

      rpm -e $(rpm -qa *nautilus*)

      --

      jh

    18. Re:can't eat just one by vidnet · · Score: 1

      (Yes, I prepare my comments in vi, then cut and paste, don't even try to make me use some GUI text widget editor and claim it can be productive.)

      How about Yzis? It's a vim clone designed for guis and embeddability without major hacks, and can work as the text area editor in konqueror.

      And I hope you just misspelled "I prepare my comments in vim". Vim isn't vi, and vi isn't vim. They share some concepts, but so does notepad and emacs.

      (queue the notepad-emacs comparison jokes)

    19. Re:can't eat just one by yagu · · Score: 1

      Hi vidnet, thanks for the suggestion. I'm going to check into it. I wonder if I can plug it into FireFox (and even some e-mail clients, that would be nice).

      As for your comment: And I hope you just misspelled "I prepare my comments in vim". Vim isn't vi, and vi isn't vim....

      I think the full context of my statement was more correctly: Okay, the tool I'm using now: vim, derivative of Bill Joy's vi, with color syntax and a bounty of enhancements. So, I was not only making the distinction between vim and vi, I attributed Bill Joy as vi's author (though I remember using a precursor to vi that was VERY much like vi called "sc" (short for screen). It was included with AT&T SysV way, way back.).

      Again thanks much for the suggestion... and "hey" to a fellow vi user.

    20. Re:can't eat just one by yagu · · Score: 1

      Hi vidnet, thanks for the suggestion.

      (Hmmm, weird, could swear I replied to this, must have only gone as far as preview and forgot to submit.)

      I've always looked for vi-alike plugins for as many environments as possible. Life would be great if things like OpenOffice had a vi mode. (Not asking others to be vi-ers, just let me have my interface... I'm at least a factor of 2 or 3 more efficient editing text in vi.) 'Twould be nice if I could plug it into FireFox (and even Thunderbird).

      As for your post about vi vs. vim, look at my statement before your quote:

      Okay, the tool I'm using now: vim, derivative of Bill Joy's vi, with color syntax and a bounty of enhancements.

      So, you see I did distinguish between vim and vi and even attributed Bill Joy as the original author! (Though vi seems very much derivative of the first character-based fullscreen text editor I encountered in Unix called "sc" (short for screen). "sc" was available with ATT SysV Unix many, many years ago.)

      Again, thanks much for the suggestion, and "hey" to a fellow vi-er.

      Regards, yagu

    21. Re:can't eat just one by cloudmaster · · Score: 1
      find . -name "*.o" | xargs rm -f --
      That'll reduce the number of times rm is called (xargs gets the maximum command line length and puts as many of the passed-in args on the end as possible) *and* work better than the ${} method (which is the same as the `` method, basically) in case there are too many args to fit on a single command.

      xargs is cool.
    22. Re:can't eat just one by cortana · · Score: 1

      Probably something like:

      cat "$HISTFILE" >> ~/.uber_bash_history

  4. pbcopy and pbpaste by inio · · Score: 1
    1. Re:pbcopy and pbpaste by JFitzsimmons · · Score: 1
      --
      Beware he who would deny you access to information, for in his heart he dreams himself your master. -Anonymous
  5. Here's mine by Henry+V+.009 · · Score: 5, Funny
    My most important tools as a system admin:
    alias rm 'rm -rf \!*'
    alias hose kill -9 '`ps -augxww | grep \!* | awk \'{print $2}\'`'
    alias kill 'kill -9 \!* ; kill -9 \!* ; kill -9 \!*'
    alias renice 'echo Renice\? You must mean kill -9.; kill -9 \!*'
  6. What you mean besides... by jonadab · · Score: 1

    perl

    --
    Cut that out, or I will ship you to Norilsk in a box.
  7. cp.php by biryokumaru · · Score: 1

    I found this little php script called "cp.php" which I renamed pcp and use for mundane cp whenever I'm in a tty and hafta do lotsa copying. It gives lotsa info about progress of copying and such, which I really like compared to the rather spartan cp function. It may be somewhat superfluous, but it's nice eye candy in a bash, and nice for moving lotsa big files.

    Someone with more Google skills than I might be able to find it online. I got it from sourceforge originally, but it doesn't seem to show up in their search any more (not that anything usually does =/ )

    --
    When you're afraid to download music illegally in your own home, then the terrorists have won!
  8. a funny Microsoft diff story. by yagu · · Score: 1

    I was on a special project, tucked away in a secret office in Seattle. We were creating a workbench of sorts using one of the very first PC networks in our company (it was 1986). Five of us created hundreds of files and thousands of lines of code and balanced version control ad hoc and on-the-fly. The project was a success.

    One day though, I'd transferred an image of our work from one machine to another. When I "ls'ed", oooops, I mean "dir'ed" the directory structures on the two machines they did not match. WTF? Hey wait, DOS has a diff command! Phew!

    I dir'ed the tree structures of the two mismatched machines into machine1.dir and machine2.dir and issued the command: c:> diff machine1.dir machine2.dir

    and the system replied: files are different . Wow! Strong stuff. I found a way to get the two files to a unix box and used a real diff command. Sigh.

    1. Re:a funny Microsoft diff story. by pclminion · · Score: 1

      That's not quite a fair comparison... DOS 'diff' is really more equivalent to UNIX 'cmp', not UNIX 'diff'.

    2. Re:a funny Microsoft diff story. by Anonymous Coward · · Score: 0

      Okay, then what it the analogous command to diff in DOS?

    3. Re:a funny Microsoft diff story. by pclminion · · Score: 1
      Okay, then what it the analogous command to diff in DOS?

      There isn't one. My point was just that comparing diff to diff wasn't really comparing the same things. DOS just out and out lacks the functionality.

    4. Re:a funny Microsoft diff story. by ltskinol · · Score: 1

      Try fc.

      Works not-too-bad.

    5. Re:a funny Microsoft diff story. by Anonymous Coward · · Score: 0

      There isn't one, unless you go third party. They have windiff in Windows, which can be found along with Visual Studio. I remember seeing it in one of the Windows Resource kits once too, but it's not part of the 2003 Server Resource kit.

    6. Re:a funny Microsoft diff story. by Glonoinha · · Score: 1

      JFC in ZTree - it's a bad ass implementation of diff for use in the DOS world.
      Heck, get familiar with it and you will be FTPing your files down to your DOS box just to diff them - it's that good.

      --
      Glonoinha the MebiByte Slayer
  9. cp -g by ReKleSS · · Score: 2, Informative

    I don't know how much information your script gives, but cp -g gives you a progress bar, transfer rate, completion percentage and other stuff when a transfer is going to take more than a few seconds (similar to what scp gives you). It's sometimes a handy feature to have, sounds like what your script is doing...
    -ReK

    --
    md5sum -c reality.md5
    reality: FAILED
    md5sum: WARNING: 1 of 1 computed checksum did NOT match
    1. Re:cp -g by biryokumaru · · Score: 1

      Haha, I am clearly a CLI noob! Thank you =]

      --
      When you're afraid to download music illegally in your own home, then the terrorists have won!
    2. Re:cp -g by croddy · · Score: 1

      whose 'cp' you usin dude? gnu coreutils cp says 'invalid option -- g'.

    3. Re:cp -g by jrockway · · Score: 1

      Yes, GNU cp and BSD's cp do not have this "feature". "cp -v" is enough information for me, though.

      --
      My other car is first.
    4. Re:cp -g by ReKleSS · · Score: 1

      Eh?
      [rek@SigSeg:~] $ cp --version
      cp (coreutils) 5.2.1

      This is the version currently used by Gentoo.

      [rek@SigSeg:~] $ cp --help
      ...
        -g, --progress               show a progress bar if operation is going to take a long time
      ...

      I always took -g for granted, now I noticed that my openbsd box doesn't have it.

      --
      md5sum -c reality.md5
      reality: FAILED
      md5sum: WARNING: 1 of 1 computed checksum did NOT match
    5. Re:cp -g by BinLadenMyHero · · Score: 1

      The version currently used by Slackware, which also says it's 5.2.1, don't have this option either.
      I checked linuxpackages.net, and found that this version is from Slackware 9.1 (current is 10.2), so it's pretty old.
      Perhaps this is a new option in the nightly, or an unofficial patch?

    6. Re:cp -g by MarkRose · · Score: 1

      I am also using coreutils version 5.2.1 that comes with Ubuntu stable, and it also does not have the `-g' option.

      --
      Be relentless!
    7. Re:cp -g by PotPieMan · · Score: 1

      Gentoo patches coreutils to add that feature.

    8. Re:cp -g by Anonymous Coward · · Score: 0

      Gentoo has a coreutils patchset that includes several extras like the progress bar for cp. They're at http://dev.gentoo.org/~vapier/dist/

      The one Gentoo is currently using for 5.2.1 is coreutils-5.2.1-patches-1.0.tar.bz2. The patch file for just the progress bar is patch/generic/001_all_coreutils-gen-progress-bar.p atch within the archive.

    9. Re:cp -g by J'raxis · · Score: 1

      Even though the programs are meant for remote copying, you can use either `scp` or `rsync` (`rsync --progress`) to do local-to-local copying. As long as the destination name doesn't have a colon in it, the programs treat the destination as a local target.

    10. Re:cp -g by croddy · · Score: 1

      the "-g" must stand for "gentoo"

    11. Re:cp -g by nachoboy · · Score: 1

      I have been searching for something like this (progress bar, eta, etc. for copy operations) for native Win32 for over 2 years. I've seen the unxutils page, but the cp.exe included in that package doesn't support the -g parameter. I pride myself in being able to accomplish more via the command line in both Windows and *nix environments, but lack of progress information makes me resort to the GUI for large file transfers (> 2 GB). Moving platforms and using Cygwin are not viable alternatives, but if anyone has any other suggestions, I welcome them. (I can't even find someone to take my money; $40 for XXCopy gets you every feature under the sun and only a pop-up GUI progress bar! wtf?!?)

    12. Re:cp -g by swmccracken · · Score: 1

      Well, if you're copying whole directories, may I recommend ROBOCOPY. Produced by Microsoft themselves, it's part of the Windows 2000 and Windows 2003 resource kit tools.

      The syntax is slightly different (very slightly) - robocopy source-directory destination-directory [optional wildcard]. But it's free, fast, console, has a percentage counter (optional ETA as well), can mirror one tree into another. (ie: only copy files that have different dates/times/sizes, deleting files in the target that no longer exist in the source), and can copy NTFS Security while it's at it.

      It may have originally been a demo for the Win32 API "FileCopyEx" call.

      Seriously, if you do much file copying at all (especially as an automated/scheduled task), check this tool out.

    13. Re:cp -g by PotPieMan · · Score: 1

      Perhaps, but the original patch also uses -g. I don't believe Miika Pekkarinen has any association with Gentoo.

    14. Re:cp -g by nachoboy · · Score: 1

      Well, if you're copying whole directories, may I recommend ROBOCOPY.

      While I do love the Resource Kit Tools, I hadn't used robocopy extensively before. I read through the robocopy documentation, and it appears that robocopy is designed almost solely for copying directories rather than files. There is, for example, no way to copy a file to the same directory with a different name (eg copy importantfile.ext importantfile.bak). It looks like robocopy gets me much closer to what I'm looking for (thanks!) but it's not yet the One True Tool.

      Seriously, if you do much file copying at all (especially as an automated/scheduled task), check this tool out.

      Make that "...if you do much directory copying..."

  10. CTRL + L by Kizzle · · Score: 2, Insightful

    Every person I see using linux clears the screen by typing CLS. The key combo "CTRL + L" is so much sexier.

    1. Re:CTRL + L by BradyB · · Score: 1

      lol, beautiful! never knew this one.

      --

      Good is never enough, when you dream of being great!
    2. Re:CTRL + L by AntiNeutrino · · Score: 1

      which reminds me:

      do you ever find you've switched two letters around?
      i.e. you type "umoutn" instead of "umount"

      well then just track back to the n and press CTRL+T

      --
      I can't even remember what it was I came here to get away from - Bob Dylan
    3. Re:CTRL + L by AntiNeutrino · · Score: 1

      and I forgot:

      If you're really cool you'll type all the letters you need for a given command and then put them in the correct order using CTRL+T in Bubble-Sort Style!

      --
      I can't even remember what it was I came here to get away from - Bob Dylan
    4. Re:CTRL + L by pclminion · · Score: 2, Interesting
      CTRL+L in almost any terminal application forces a terminal redraw. Comes in handy when the application doesn't explicitly detect SIGWINCH, and you want to resize the terminal window. Resize, then hit CTRL+L to inform the app that the window size changed.

      I wish the behavior was the same in bash, but for some reason they chose to make it clear the screen instead.

    5. Re:CTRL + L by JFitzsimmons · · Score: 1

      cls is DOS. clear is UNIX. ^L is a cool one though, thanks!

      --
      Beware he who would deny you access to information, for in his heart he dreams himself your master. -Anonymous
    6. Re:CTRL + L by theCoder · · Score: 1

      Other useful control combinations:

      ^D -- end of file, logs out of most shells, and exits programs looking for user input
      ^S -- stop terminal output (useful if you're watching make output and see something scroll by too quickly)
      ^Q -- resume terminal output. Before learning this one, everything I accidently hit ^S (save reflex), I had to kill the terminal
      ^Z -- suspend. Stops a foreground process and gives you your command line back. Useful for GUI apps you started without '&'. Also useful with the 'bg' command.
      ^R -- (bash specific?) reverse search through the history for the string typed next. Very useful if you know you typed a specific command a while ago, but don't want to hit the up arrow 20 times (or grep through 'history' output)

      and of course, there's always ^C, but most people know that one.

      --
      "Save the whales, feed the hungry, free the mallocs" -- author unknown
    7. Re:CTRL + L by AntiNeutrino · · Score: 1

      don't forge CTRL+T
      here and here

      --
      I can't even remember what it was I came here to get away from - Bob Dylan
    8. Re:CTRL + L by fimbulvetr · · Score: 1

      I've been using linux since 98, and have been a sysadmin since 2000. I never knew how to get my ^s sessions back, for this, I owe you a beer. I see your homepage says slashdot.org, I will send it there.

      It never fails when I go for ^a to get to the beginning of the line, I hit ^s.

    9. Re:CTRL + L by SharpFang · · Score: 1

      Come on. It lights up "scroll lock" on your keyboard. Pressing "scroll lock" then does the same as ctrl+Q

      --
      45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
    10. Re:CTRL + L by fimbulvetr · · Score: 1

      Really? Well, chalk it up to ignorance on my part, I'm usually so frustrated I just close the terminal. I use konsole and usually have about 10-20 tabs open. If I hit ctrl-s, I can close that tab and keep working in another. I wonder if it turns scroll lock on for the session, but not the entire computer I'm sshing from? For instance, caps locks is specific to my workstation, if I turn caps lock on, it doesn't turn off when I close that session I was in, but the "ctrl-s" just scroll locks the session I'm in. Maybe I'll experiment when I get bored.

    11. Re:CTRL + L by Intron · · Score: 1

      Now I feel old. ^S and ^Q are around since flow control for serial terminals, predating the net. A related command when some program has screwed up your terminal settings, and you need to restore without being able to see what you type is:

      stty sane

      --
      Intron: the portion of DNA which expresses nothing useful.
  11. This works good for me by Kawahee · · Score: 0

    rm -r -f /mnt/windows/*

    --
    I'll subscribe to Slashdot when I see a month without a dupe, a typo, or an article the "editors" didn't read.
    1. Re:This works good for me by billieja2 · · Score: 1

      that is so boring and such over done.

    2. Re:This works good for me by billieja2 · · Score: 1

      also, it's less typing to use rm -rf /mnt/windows/*

    3. Re:This works good for me by Anonymous Coward · · Score: 0

      Why the hell would you set a mount point within a system folder like /mnt? That's just begging for trouble.

      Jeez.

    4. Re:This works good for me by stderr_dk · · Score: 1

      It's even less typing to not install the damn thing at all...

      --
      alias sudo="echo make it yourself #" ; # https://pipedot.org/~stderr & http://soylentnews.org/~stderr
    5. Re:This works good for me by Anonymous Coward · · Score: 0

      You, sir, are an asshat.

  12. skill by cgenman · · Score: 2, Insightful

    I'm not much of a linux guru, so my favorite is simple.

    skill

    s-kill, basically, kills a process by name. "skill netscape" will kill netscape, no finding proc ID required. It's what kill should have been from the beginning.

    The only command I love more than skill is apt-get, but that doesn't really count.

    1. Re:skill by biryokumaru · · Score: 1

      man skill : skill, snice - send a signal or report process status There's also: man killall : killall - kill processes by name I got annoyed by having to find the proc ID in top too, and stubled across killall. Haha =]

      --
      When you're afraid to download music illegally in your own home, then the terrorists have won!
    2. Re:skill by biryokumaru · · Score: 1

      Oops... I forgot my html tags =[ Shoulda been:

      man skill : skill, snice - send a signal or report process status

      There's also:
      man killall : killall - kill processes by name

      I got annoyed by having to find the proc ID in top too, and stubled across killall. Haha =]

      --
      When you're afraid to download music illegally in your own home, then the terrorists have won!
    3. Re:skill by Fweeky · · Score: 3, Informative
      Looks like killall to me:
      SYNOPSIS
          killall [-delmsvz] [-help] [-j jid] [-u user] [-t tty] [-c procname]
                  [-SIGNAL] [procname ...]
       
      DESCRIPTION
          The killall utility kills processes selected by name, as opposed to the
          selection by pid as done by kill(1). By default, it will send a TERM
          signal to all processes with a real UID identical to the caller of
          killall that match the name procname. The super-user is allowed to kill
          any process.
      Though you need to be careful with that if you admin other systems like Solaris ;)

      pkill/grep are nice too, and are standard on a fair few systems now.
    4. Re:skill by BinLadenMyHero · · Score: 0

      After finding some situations (in different machines) that killall somehow don't work, I stopped using it at all, and now I go:

      kill `pidof programname`

    5. Re:skill by sudog · · Score: 1

      kill `ps auxww | grep -i processname | grep -v grep | awk '{ print $2 }'` ... only wimps use pgrep and pkill..!

    6. Re:skill by fimbulvetr · · Score: 1

      p.s. Don't use killall in solaris. I learned the hard way:)

      System Administration Commands killall(1M)

      NAME
                killall - kill all active processes

      SYNOPSIS /usr/sbin/killall [signal]

      DESCRIPTION
                killall is used by shutdown(1M) to kill all active processes
                not directly related to the shutdown procedure.

                killall terminates all processes with open files so that the
                mounted file systems will be unbusied and can be unmounted.

                killall sends signal (see kill(1)) to the active processes.
                If no signal is specified, a default of 15 is used.

                The killall command can be run only by the super-user.

  13. Just the right command? by Anonymous+Brave+Guy · · Score: 1

    What little-known command performs just the right function for me?

    strip, of course.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:Just the right command? by alan_dershowitz · · Score: 1

      I'm sure you've heard the ubiquitous:

      # unzip
      # strip
      # touch
      # finger
      # mount
      # fsck
      # more
      # yes
      # umount
      # sleep

      for the gamut of unix double entendres...

    2. Re:Just the right command? by Anonymous Coward · · Score: 0

      Psh, your sig would be quickly demolished in ordinary debate! =p

  14. my favorite... by Anonymous Coward · · Score: 0

    'jkmehof' always get the job done.

  15. ls -d without the subcontents by bergeron76 · · Score: 2, Informative

    I never figured out a way to use 'ls' to show only directories (and not their subcontents), so I created an alias called 'lsd':

    alias lsd='\ls -l | grep "drwx"'

    and placed it in my .bash_profile

    It's quite useful, but it doesn't work well with shell scripts.

    --
    Don't think that a small group of dedicated individuals can't change the world. It's the only thing that ever has.
    1. Re:ls -d without the subcontents by pclminion · · Score: 5, Informative
      Dude...

      ls -d */

      The final slash is key.

    2. Re:ls -d without the subcontents by Nutria · · Score: 2, Informative
      alias lsd='\ls -l | grep "drwx"'

      What if a file has the string "drwx" in it?

      And you forgot about dot directories.

      alias lsd='ls -al | grep ^d'
      --
      "I don't know, therefore Aliens" Wafflebox1
    3. Re:ls -d without the subcontents by Anonymous Coward · · Score: 0
      I assume you can figure this out yourself, but just in case... The above doesn't display directories starting with a dot. The complete command would be:

      ls -ad */ .*/

    4. Re:ls -d without the subcontents by bergeron76 · · Score: 1

      Cool. Thanks for the tip, I'll set that as my 'lsd' alias instead!

      --
      Don't think that a small group of dedicated individuals can't change the world. It's the only thing that ever has.
    5. Re:ls -d without the subcontents by pclminion · · Score: 1

      Glad to share the info... Possible caveat, I haven't tested on anything except bash.

    6. Re:ls -d without the subcontents by sootman · · Score: 2, Interesting

      try ls -F | grep /

      '-F' shows a slash after each entry that's a directory, an asterisk after each executable, and some other things. Read the man page for 'ls' sometime, it's like a whole freaking operating system.

      NAME
                ls - list directory contents

      SYNOPSIS
                ls [-ABCFGHLPRTWZabcdfghiklmnopqrstuwx1]

      By the way, my favorite script fu is `du -sh ./*` to show how much room each file takes up, and it adds up directories also--just like 'calculate folder sizes' has done in Mac OS for a decade.

      --
      Dear Slashdot: next time you want to mess with the site, add a rich-text editor for comments.
    7. Re:ls -d without the subcontents by bergeron76 · · Score: 1

      Do you have a similar solution for du -S?

      --
      Don't think that a small group of dedicated individuals can't change the world. It's the only thing that ever has.
    8. Re:ls -d without the subcontents by Matt+Perry · · Score: 1

      du -sS */ should do what you want.

      --
      Slashdot: Failed Car Analogies. Amateur Lawyering. Anecdote Battles.
    9. Re:ls -d without the subcontents by DJCater · · Score: 1

      Or you could do this to be safe:

      ls --classify | grep --regexp='/$';

      --
      Sig Appended to the end of comments you post. 120 chars.
    10. Re:ls -d without the subcontents by jregel · · Score: 1

      ls -l | grep ^d

      This will give a long listing for lines starting with "d" (i.e. a directory). Pipe the output to awk if you just want the directory name at the end.

  16. Yeeah baby... by LadyPixel · · Score: 1

    I tried mv... renaming a whole bunch of files... nah gwan. So rename came and rescued me. But you know what really presses my keys? #] startx. Yeeah baby!

  17. The best is by Tom7 · · Score: 1

    emacs, whose shell mode and keyboard macros have totally replaced the crude shell-or-worse scripts that one writes and debugs to perform repetitive daily tasks.

  18. perl by Turmio · · Score: 5, Insightful

    First, I must comment the article. Question goes What little known command performs just the right function for you? I hope all sane people here (haha) would answer "None". There's no command that does just the right function since there's no one The Function. It depends on the situation what the function is. And in that case, per Unix philosophy, where one tool does one simple job, but does it well, you should choose the tool accordingly.

    Enough of that. If you really must name something, then, in my opinion, there's one gizmo above others. And that is

    perl

    Perl one-liners is a damn powerful concept when you get it. Say one of your boxen switches IP address. You want to replace all references in files under /etc to this new IP address. First you might think searching all the files under /etc with find(1), then passing the list of files to grep(1) and then manually editing the places where the old IP address was found with your $EDITOR. That's fine and will get the job done and all but what if you could just edit the files in place? With perl, you can.

    perl -pne's/oldip/newip/g' -i `find /etc -type f`

    and you're done (better be extra careful with commands like that for obvious reasons!). Of course you're able to do the same thing with other tools too, but I don't think it could be much easier than that. And naturally you're not just limited to simple search and replace of text, you have the full power of Perl (and CPAN!) at your disposal.

    Besides being my number one choice for creating complex scripts and small applications, Perl has very special place in my command line toolbox just next to the old friends such as grep(1), cut(1), wc(1), etc. and a huge pile of pipes :)

    1. Re:perl by davegaramond · · Score: 2, Interesting

      Second that. "Traditional" Unix tools sometimes just don't cut it (or they do, but requires significantly longer typing and multi-piping work).

      I use this all the time:

      $ perlrename -e's/.\[www.descargasweb.net\]//' *
      $ perlrename -e's/.\[www.\S+?\]//' *
      $ perlrename -e'$_=lc' *
      $ perlrename -de's/Sex And The City - S(\d+)E(\d+)/SATC - $1$2/ig' Sex*
      etc etc

      where perlrename is a 30-something perl script.

    2. Re:perl by BinLadenMyHero · · Score: 1

      perl -pne's/oldip/newip/g' -i `find /etc -type f`

      Hun? `man perlrun` says -p overrides -n
      I don't see how this will work. Either way, it would edit all files, not only the ones wich has the 'newip' string.

    3. Re:perl by bergeron76 · · Score: 1

      How platform specific you are!

      Perl / PHP is not a killer solution for everything. Particularly, if you use an embedded system that doesn't have php/perl installed, you'll find that bash/busybox is very much your friend.

      That said, I love php and don't know that I'd do without it (aside from use bash for everything).

      --
      Don't think that a small group of dedicated individuals can't change the world. It's the only thing that ever has.
    4. Re:perl by Anonymous Coward · · Score: 0

      You're right, but that must be a reltively recent change. In the old days, -n did the loop and -p printed the result ; you needed both.

    5. Re:perl by Anonymous Coward · · Score: 0

      find /etc -type f -print0 | xargs -0 sed -i 's/oldip/newip/g'
      Is safer especially if file names have spaces. And it doesn't use that mess called perl.

  19. groff by (1+-sqrt(5))*(2**-1) · · Score: 2, Interesting
    groff -ms -t -Tascii <file>.ms
    is how I code all my outgoing emails; that's GNU troff with the ms macro package and tbl preprocessor.

    Justifies nicely said paragraphs; provides lists and sigart.

  20. Junction for Windows by alan_dershowitz · · Score: 3, Informative

    Junction lets you make symlinks in Windows without installing the entire Windows Resource Kit tools. Also, CACLS.EXE for changing ACLs in Windows via the command line, since I have no fucking clue where you do this in the GUI. Some of the more usefule CLI commands in Windows, IMO. I hope this discussion wasn't limited to Unix or anything.

    1. Re:Junction for Windows by ConceptJunkie · · Score: 2, Informative

      I hope this discussion wasn't limited to Unix or anything.

      It shouldn't be. Another source of good command line tools is sysinternals.com.

      The pstools let you do all kinds of nifty things that are sometimes covered by RK utils, but the sysinternals stuff is usually way better... ...with one exception that drives me crazy. pslist is their version of ps, which I just alias using 4NT, however they don't echo the banner to stderr like most utils, so if you sort the list looking to see if you need to kill and errant process of Firefox 1.5 beta 1, you get the banner sorted with the list of processes.

      Other than that, they are great tools.

      You can easily control services on other machines ("net" might let you do this but I don't know how), you can even defrag with "contig". Heck there's even a blue screen screen saver. At one place, years ago I used to run this to encourage people not to mess with my machine.

      Of course no Windows command line would be complete without cygwin in the path.

      --
      You are in a maze of twisty little passages, all alike.
    2. Re:Junction for Windows by BrynM · · Score: 3, Informative
      without installing the entire Windows Resource Kit tools
      There are several RK tools in my MS toolbox, but the best thing is having real unix utils. Pop those in your %PATH% and enjoy some of the same fun that's being spoken of here. Of course there's always Cygwin, but these native ports are handy to keep on a USB drive and don't need any configuration/installation at all.
      --
      US Democracy:The best person for the job (among These pre-selected choices...)
    3. Re:Junction for Windows by BrynM · · Score: 1
      You can easily control services on other machines ("net" might let you do this but I don't know how)
      You can schedule one remotely by using
      at \\servername 11:30 "net stop servicename"
      It's an old trick from the NT4 days ;) At is very handy for that sort of thing. We used it remotely all the time in the days before VNC.
      --
      US Democracy:The best person for the job (among These pre-selected choices...)
    4. Re:Junction for Windows by bergeron76 · · Score: 0, Troll

      Some of the more usefule CLI commands in Windows, IMO. I hope this discussion wasn't limited to Unix or anything.

      No this discussion isn't limited to "Unix or anything". The only limitation here is basic grammar.

      --
      Don't think that a small group of dedicated individuals can't change the world. It's the only thing that ever has.
    5. Re:Junction for Windows by ConceptJunkie · · Score: 1

      Nice. There's a lot of great stuff you can do with Windows if you look past the GUI. The hardest part is finding out about it. I'd never heard of robocopy until I worked with an ex-Microsoftie.

      Now I use it all the time.

      p.s. Did you spell "asinine" wrong on purpose?

      --
      You are in a maze of twisty little passages, all alike.
    6. Re:Junction for Windows by Anonymous Coward · · Score: 0

      For those not familiar with Junction, be careful. You don't want to delete a folder you junction'ed accidentally...like I did. Thank goodness for undelete tools!

    7. Re:Junction for Windows by sudog · · Score: 2, Insightful

      Why waste your time fighting with DOS commands?

      UNIX Utils, Natively Compiled for Windows

    8. Re:Junction for Windows by ConceptJunkie · · Score: 1

      Well, first off I use 4NT which is a superscript of the CMD shell with far more capabilities (i.e., it's a real shell), and secondly I have cygwin in the path. I think I'm pretty well covered in that respect.

      --
      You are in a maze of twisty little passages, all alike.
    9. Re:Junction for Windows by swmccracken · · Score: 1

      Right click on the file. Properties. Security Tab. Or just look it up in the online help.

      Umm.. really, you perhaps shouldn't be trying to admin a Windows box if you haven't found where in the GUI the NTFS permissions are set.

      Okay, so I just dug into it, I think it's delibrately hidden from the GUI if you're using XP Home (or XP Home is jammed into "Simple file sharing/security mode" or something.) But believe me, it's easy to find on 2000 and 2003; and I think XP Pro.

    10. Re:Junction for Windows by alan_dershowitz · · Score: 1

      I'm not a Windows admin, but I do have to mess with security settings on Windows sometime. It's not my job, but something I have to do frequently, nonetheless. I know where the tab is in 2000, but XP pro doesn't seem to have it, which threw me for a loop. Why would they move this? I guess too many people messed with it and screwed stuff up, so everyone was punished.

    11. Re:Junction for Windows by swmccracken · · Score: 1

      It's definitely there on my XP Pro Box at work! I think it's there by default on Domain Member computers - but hidden by default on Workgroup computers.

      Anyway, you need to turn off "Simple File Sharing" - see this page.

      (XP Home only supports Simple, 2K3 only supports "full", XP Pro can do either.) That whole article walks you through the whole process.

    12. Re:Junction for Windows by mat.h · · Score: 1
      changing ACLs in Windows via the command line, since I have no fucking clue where you do this in the GUI
      Ah, the joys of Windows XP home edition. Try this little shell extension that puts the necessary property pages where they belong.
  21. Looking around. by jZnat · · Score: 1

    I find myself typing "cd 'somewhere, probably with a tab auto-completion'" followed by an immediate "ls" or "ls -l".

    Next most use(d|ful) would be tar, grep, and info/man. Oh yeah, and "gv", my own symbolic link to gvim. Of course, you can't forget sudo...

    --
    'Yes, firefox is indeed greater than women. Can women block pops up for you? No. Can Firefox show you naked women? Yes.'
    1. Re:Looking around. by Lord+Bitman · · Score: 1

      sounds like you want.. damnit, can't find it.. anyway, it was basically a zork-style shell.

      --
      -- 'The' Lord and Master Bitman On High, Master Of All
    2. Re:Looking around. by jZnat · · Score: 1

      zsh?
      There are plenty of shells, but I've preferred using bash so far.

      --
      'Yes, firefox is indeed greater than women. Can women block pops up for you? No. Can Firefox show you naked women? Yes.'
    3. Re:Looking around. by AnuradhaRatnaweera · · Score: 1
      Oh yeah, and "gv", my own symbolic link to gvim.
      `gv' is the name of the ghostview binary.
    4. Re:Looking around. by jZnat · · Score: 1

      Nah, I have ggv for that. Besides, I don't really use GhostView. And by symbolic link, I actually meant alias. >_>

      --
      'Yes, firefox is indeed greater than women. Can women block pops up for you? No. Can Firefox show you naked women? Yes.'
  22. dusort by RGRistroph · · Score: 2, Informative

    in bash:

    function dusort ()
    {
      du -s "$@" | sort -r -n |
        awk '{sum+=$1;printf("%9d %9d %s\n",sum,$1,$2)}' ;
    }

    in tcsh:

    alias dusort 'du -s \!* | sort -r -n | awk '"'"'{sum+=$1;printf("%9d %9d %s\n",sum,$1,$2)}'"'"

    The most common way to use those commands would be:

    cd /home/
    dusort *

    It's useful for tracking down what's using up your space, for example finding a sub directory deep in a source tree that isn't cleaned by make clean.

  23. hmm... by bbrack · · Score: 2, Informative

    perl -pi -e "s/x/y"

    ever had to make a change to every line in a test vector (up to several million lines long), but didn't have the half hour it would take to retranslate the whole thing? - has saved my ass more than anything I can think of
    also fun to do something like

    perl -pi -e "s/(alias \w) \'.+\'/$1 \'echo \"DFU DFU DFU\"/g ~user/.aliases

    1. Re:hmm... by Anonymous Coward · · Score: 0

      perl -pi -e "s/x/y"

      At first I thought the "/y" was some sort of switch I didn't know about. Then I noticed you left off the last slash.

    2. Re:hmm... by bbrack · · Score: 1

      oops...


      guess that's why I always run it on a test case before I run it on the full file :P

  24. Midnight Commander by G-Licious! · · Score: 1

    mc, anyone?

    Easy utility to pick up when you're coming from a DOS/Windows background. It's how I started off, and I stuck with it. It's embedded editor is also my favorite source editor, though I still haven't gotten around to changing the syntax highlighting colors. (dark red comments on a blue background? yech..)

  25. ls -t | head by ArmorFiend · · Score: 2, Interesting

    ls -t | head
    This is nice for listing the 10 most recently modified files. Usually the one you want is the first or second one.

    1. Re:ls -t | head by BinLadenMyHero · · Score: 1

      Or just

      ls -rt

      so they will appear last, near the prompt.

  26. rsync by metamatic · · Score: 1

    I can't believe nobody's mentioned rsync yet. It has to be the single best command line tool ever.

    I use it to update my web site. I use it to synchronize bookmarks between multiple machines. I use it for online incremental backups. I use it to copy directory trees around from disk to disk.

    I even use it to fetch my mail. Yes, I switched my mail account to Maildir by using procmail for final delivery, and now I can use rsync -avz --remove-sent-files instead of crappy POP3 or IMAP protocols to pull the mail down to a fast local server.

    If I ever meet Andrew Tridgell or Paul Mackerras, they definitely deserve a beer or three...

    --
    GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
    1. Re:rsync by Anonymous Coward · · Score: 0

      It is a great command, however it falls down flat on its face for nontrivial copies. For example, on the small file server at work with just over 1M files, rsync takes over 2Gbytes of RAM to run. There's no excuse for programming that sloppy. I'm not doing anything unusual. The command line is simply:

      rsync -avzH --delete file_server:/export /bak

    2. Re:rsync by Anonymous Coward · · Score: 0

      My 1M was a typo. I typed that in as a place holder while I waited on the ls -lR to finish, but I forgot to go back and change it. There's actually 22M files on our small file server. That absolutely brings rsync to its knees. About 9 times out of 10 we get this:

      ERROR: out of memory in flist_expand

      Which is strange since we have 4Gbytes of swap, and most of it is free.

      The other thing that makes rsync useful for nontrivial applications is that it waits so long before it starts copying files. Even with a gigabit network and two fast servers, this message:

      receiving file list ...

      is displayed for over 48 hours before rsync actually begins copying files. That means our backups are usually >15 days old on average since it takes rsync 6 days to run when it doesn't crash.

  27. BASH by SilverspurG · · Score: 1

    I like installing packages from tarballs so I wrote a neat little utility to help me automate the process. It's a line parser for command files coupled with a mini database. All written in BASH. It's about 15k.

    --
    fast as fast can be. you'll never catch me.
    1. Re:BASH by Matt+Perry · · Score: 1

      Sounds neat. Would you be willing to publish the code somewhere so I could try it out?

      --
      Slashdot: Failed Car Analogies. Amateur Lawyering. Anecdote Battles.
    2. Re:BASH by SilverspurG · · Score: 1

      Follow the link to my home page. The code is GPL.

      --
      fast as fast can be. you'll never catch me.
  28. We're not talking about cool commands, here! by pclminion · · Score: 2, Informative
    I don't think the point of the article is to discuss which commands are coolest, rather, what ways can you combine those commands to achieve powerful results?

    Here's something that I run via cron on a nightly basis. See if you can decode its function :-)

    for F in $(find $SRCDIR); do echo $(basename $F) $F; done | sort | rev | uniq -c -f 1 | grep -E ^[[:space:]]*1[[:space:]] | awk '{print $2 " " $3}' | rev > $CACHEFILE

    1. Re:We're not talking about cool commands, here! by S.+Traaken · · Score: 1

      for F in $(find $SRCDIR); do echo $(basename $F) $F; done | sort | rev | uniq -c -f 1 | grep -E ^[[:space:]]*1[[:space:]] | awk '{print $2 " " $3}' | rev > $CACHEFILE

      Finding files without duplicate names (or something). Not quite sure why you're using the revs either - echo $F $(basename $F) would eliminate the need?

      Whatever it does, it doesn't work well with filenames containing spaces :)

    2. Re:We're not talking about cool commands, here! by pclminion · · Score: 1
      Not quite sure why you're using the revs either - echo $F $(basename $F) would eliminate the need?

      I can't remember any more (of course), but I believe the revs eliminated one call of awk somehow, and rev is much faster than awk, so...

      My documentation-fu is weak in shell scripts.

  29. screen by pauljlucas · · Score: 5, Informative

    Multiple multiplexed ttys that stay running even after disconnect and you can reattach to them later.

    --
    If you reply, do so only to what I explicitly wrote. If I didn't write it, don't assume or infer it.
    1. Re:screen by Tamerlan · · Score: 1

      I second that. screen is THE favourite program of mine.

      My 2c to the topic:

      du -sk * .*|sort -nr|head -n 10

      shows top 10 space eaters (including directories starting with dot - cache inside .mozilla may get really big).

    2. Re:screen by eyeball · · Score: 1
      Multiple multiplexed ttys that stay running even after disconnect and you can reattach to them later.


      Hi screen brother. :) I live and breath screen -- I sometimes open multiple windows to the same screen session, but different 'screens.' I've also changed the MAXWIN value from 40 to 60 before compiling because, well, 40 screens just isn't enough.

      I had one screen session up for almost a year, which would've been longer but I upgraded my kernel.
      --

      _______
      2B1ASK1
    3. Re:screen by rthille · · Score: 1

      I had one screen session up for almost a year, which would've been longer but I upgraded my kernel.

      That's nothing, I got laid off from my job, forgot to kill my emacs session (running inside of screen), got brought back as a consultant months later and my screen session was still running where I left it.

      --
      Awesome furniture, accessories and cabinetry in Santa Rosa, CA: http://humanity-home.com/
    4. Re:screen by SharpFang · · Score: 1

      Screen for the poor

      jobs: list jobs
      ctrl-z: detach job
      bg: bring the job into backgroung
      fg: bring the job into foreground
      nohup: job won't be killed when you quit
      &: start in background.

      Been using these for some 5 years before I actually forced myself to run Screen. Actually, these are much lighter on the CPU and memory, so if you want to launch a download overnight, do wget -b and not screen -> wget

      --
      45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
    5. Re:screen by pauljlucas · · Score: 1
      If I'm launching a download overnight, I don't care how much CPU or memory is being used since I'm obviously not using the computer for anything else (I'm asleep).

      Anyway, I'm running screen just fine on my Linux box with 128KB RAM. You can continue to use your stone knives and bear skins if you want.

      --
      If you reply, do so only to what I explicitly wrote. If I didn't write it, don't assume or infer it.
    6. Re:screen by Cheeze · · Score: 1

      I don't think linux runs in 128KB RAM. :)

      Anyways, screen is awesome.

      --
      Why read the article when I can just make up a snap judgement?
    7. Re:screen by Anonymous Coward · · Score: 0

      > Anyway, I'm running screen just fine on my Linux box with 128KB RAM.
      > You can continue to use your stone knives and bear skins if you want.

      No, looks like you need them more.

    8. Re:screen by SharpFang · · Score: 1

      Well, on my 486DX66 with 16MB of RAM Screen was running like a snail (as opposed to the "poor man's tools" above).
      Somehow I doubt your Commodore 128 running Lunix can handle real Gnu Screen.

      --
      45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
    9. Re:screen by pauljlucas · · Score: 1

      Anything running in 16MB will run like a snail. I'm not running Linux (not Lunix) on a Commodore 64. Again, I'm running screen just fine. I couldn't care less whether you believe it.

      --
      If you reply, do so only to what I explicitly wrote. If I didn't write it, don't assume or infer it.
    10. Re:screen by vrai · · Score: 2, Informative
      I'd add disown to that list - under bash it detaches background jobs from the tty and allows them to continue running after session is closed (like nohup).

      Example:

      vrai@lenin $ complex_task
      ^Z
      [1]+ Stopped complex_task
      vrai@lenin $ bg %1
      [1]+ complex_task &
      vrai@lenin $ disown %1
      vrai@lenin $ exit
      The complex task continues to run in the background; though the output will be lost to /dev/null unless redirected.
    11. Re:screen by benjj · · Score: 1

      I'm running screen just fine. I couldn't care less whether you believe it.

      I think the problem is that he is replying to what you explicitly wrote and didn't assume or infer it!

    12. Re:screen by eyeball · · Score: 1

      That's nothing, I got laid off from my job, forgot to kill my emacs session (running inside of screen), got brought back as a consultant months later and my screen session was still running where I left it.

      That is so cool!

      --

      _______
      2B1ASK1
    13. Re:screen by rthille · · Score: 1

      Yeah, except for pointing out the complete lack of security and lameness of the IT department there. After all, my running process could have, at various times, opened up a connection thru the firewall to my servers at home and allowed me access into my former company. At the very least, they should have tracked down all my processes on all the servers and killed them. But hey, I'm an honest guy, and all the developers had root on all the development servers anyway, so they pretty much would have had to wipe all those boxes if they _really_ didn't trust us :-)

      --
      Awesome furniture, accessories and cabinetry in Santa Rosa, CA: http://humanity-home.com/
  30. evil clear in solaris - Re:CTRL + L by ratsg · · Score: 1
    in Solaris, if you use /usr/bin/clear instead of /usr/bin/tput clear , be aware of what is inside of the /usr/bin/clear command.



    % cat /usr/bin/clear


    #!/usr/bin/sh
    # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
    # All Rights Reserved

    # THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
    # The copyright notice above does not evidence any
    # actual or intended publication of such source code.

    #ident "@(#)clear.sh 1.8 96/10/14 SMI" /* SVr4.0 1.3 */
    # Copyright (c) 1987, 1988 Microsoft Corporation
    # All Rights Reserved

    # This Module contains Proprietary Information of Microsoft
    # Corporation and should be treated as Confidential.

    # clear the screen with terminfo.
    # if an argument is given, print the clear string for that tty type

    /usr/bin/tput ${1:+-T$1} clear 2> /dev/null
    exit


  31. Does this count? by Anne_Nonymous · · Score: 1

    FORMAT C:

    1. Re:Does this count? by Hymer · · Score: 1
      well... No, not really :
      1. on w2k and wxp: it does not work if C: is your system drive and you have booted from it.
      2. It will ask you for confirmation.
      3. It is destructive in a meaningless way...
    2. Re:Does this count? by jo42 · · Score: 1

      gdisk 1 /diskwipe

  32. find . -name '*.ext' |xargs grep -i bar by heffel · · Score: 1

    find . -name '*.ext' |xargs grep -i bar

    finds all the files having the extension 'ext' and matching the pattern 'bar'.

    1. Re:find . -name '*.ext' |xargs grep -i bar by MarkRose · · Score: 1

      Why not use find . -name '*bar*.ext' ? It's much simpler and faster.

      --
      Be relentless!
    2. Re:find . -name '*.ext' |xargs grep -i bar by sudog · · Score: 1

      xargs sucks.

      Just use -exec. It's slower, but easier and you don't have to fight with line-endings, spaces in the filenames, and stupid cli arg limitations.

    3. Re:find . -name '*.ext' |xargs grep -i bar by Anonymous Coward · · Score: 0

      In zsh, that's simply grep -i bar **/*.ext

      I don't know why other shells haven't implemented the ** glob pattern already. It's the single most useful feature I know of in zsh. In fact, unless you need unicode line editing, there's really no good reason not to switch from bash to zsh, just to get access to the ** glob pattern. It eliminates 95% of the need for the find and xargs commands.

  33. the one that impresses most people by elmegil · · Score: 2, Interesting
    Though I have no idea why, it's pretty basic:
    find . -type f -exec grep regexp {} /dev/null \;
    The tricky bit is that adding /dev/null means I will always see the filename in the output; otherwise grepping against one file only returns the matched strings.
    --
    7 November 2006: The day Americans realized corruption and incompetence weren't addressing 11 September 2001
    1. Re:the one that impresses most people by JabberWokky · · Score: 1
      I generally build it like this (this is a very trivial example, but you get the idea):

      find . -type f |grep '.thumb.gif'

      Okay, then I can eyeball the result and check it. Pipe it to less if necessary. Then up arrow and append:

      find . -type f |grep '.thumb.gif' | while read FN ; do echo "$FN"... ; rm "$FN" ; convert -geometry 200 "$( echo "$FN" | sed 's/.thumb//' )" "$FN" ; done

      I make no claim that this is better, it's just what rolls off my fingertips when working on mass groups of files. One nice thing is that you can replace find with ls or cat "listoffiles.txt" and it works the same. Or you can use a list of URLs or whatever and process them all -- the method works well in a general use rather than just on find.

      --
      Evan

      --
      "$30 for the One True Ring. $10 each additional ring!" -- JRR "Bob" Tolkien
    2. Re:the one that impresses most people by MarkRose · · Score: 1

      Very clever. It took me a bit to figure out that /dev/null is a second filename paramter to egrep, which forces it to list which file it found the matching regexp in. I'll have to remember this command!

      --
      Be relentless!
    3. Re:the one that impresses most people by _randy_64 · · Score: 2, Informative

      If you're using gnu grep, you can use the -H option (or --with-filename) instead of the dummy /dev/null argument.

      --
      I mod down all the "free iPod"-sig losers.
    4. Re:the one that impresses most people by sudog · · Score: 1

      Or even better:

      find . -type f -print -exec grep regexp \{} \; ... which works better because you get all the filenames, and you don't have to do any workarounds with /dev/null.. which might not work if you're on a weird system.

    5. Re:the one that impresses most people by elmegil · · Score: 1

      Not having seen \{} notation before but presuming that it means find all the files and substitute them at once, I see two potential problems: 1) I think /dev/null is more likely to exist than this option I've never seen before :-) and 2) grep's command line may hit some length limit if you find too many files or your path structure is too deep. At this point I'd just as likely use xargs, which can limit the length of the command line. Actually (no one expects the spanish inquisition!) I see a third potential problem: 3) what if your find only finds one file? You have no way to know that implicitly from the command itself.

      --
      7 November 2006: The day Americans realized corruption and incompetence weren't addressing 11 September 2001
    6. Re:the one that impresses most people by Anonymous Coward · · Score: 0

      From the grep man page:

                    -H, --with-filename
                                  Print the filename for each match.

    7. Re:the one that impresses most people by elmegil · · Score: 1
      --with-filename

      Hm, that sounds like a gnu-ism. I work on a lot of non-gnu systems.

      --
      7 November 2006: The day Americans realized corruption and incompetence weren't addressing 11 September 2001
    8. Re:the one that impresses most people by Minna+Kirai · · Score: 1

      find . -type f -exec grep regexp {} /dev/null \;

      Are you just making a recursive grep? Why not run grep -r, or rgrep?

    9. Re:the one that impresses most people by Minna+Kirai · · Score: 1

      Not having seen \{} notation before but presuming that it means find all the files and substitute them at once,

      It does not. Each filename is substituted once at a time.

      I think /dev/null is more likely to exist than this option I've never seen before :-)

      That syntax is an ancient part of the find command. It exists everywhere except busybox.

      grep's command line may hit some length limit if you find too many files or your path structure is too deep.

      That will never happen, because only one filename is provided each time.
      But conversely, if you were using xargs, then on some systems (old and non-GNU), you might actually hit a limit in xargs's command line size! If you don't think grep can deal with 40,000 filename arguments, why would xargs do better with the same amount?

      what if your find only finds one file? You have no way to know that implicitly from the command itself.

      Then it prints only one file, and she knows explicitly that only one was found.

      However, sudog's command is still rather odd. It's only potential advantage over grep -r is formatting. First it prints the filename, and then on the following line prints any places in that file where matches occured. Depending on the frequency of which you expect matches to occur, that might be easier or harder to read. (If files often contain multiple matches, then having the filename printed on every single line may be overkill)

    10. Re:the one that impresses most people by elmegil · · Score: 1

      Because those are GNU specific, and 90% of the systems I work on don't have them. All *nix systems support my version.

      --
      7 November 2006: The day Americans realized corruption and incompetence weren't addressing 11 September 2001
    11. Re:the one that impresses most people by Anonymous Coward · · Score: 0

      All *nix systems support my version.

      All *nix systems can get GNU installed, which is a good idea, because the native utils have other problems, like inability to scale up to especially huge input sizes.

    12. Re:the one that impresses most people by elmegil · · Score: 1

      I do support for a vendor. I have no say on whether GNU gets installed on the systems I work with.

      --
      7 November 2006: The day Americans realized corruption and incompetence weren't addressing 11 September 2001
    13. Re:the one that impresses most people by sudog · · Score: 1

      "However, sudog's command is still rather odd."

      I take that as an excellent compliment..!

      =]

      Thanks for clarifying for me, I was away for a few days.

  34. Give credit where credit is due by mister_jpeg · · Score: 5, Informative

    That's the Technical Fascist's .cshrc.

    http://www.gnu.org/fun/jokes/know.your.sysadmin.ht ml

    --
    -jpeg
    1. Re:Give credit where credit is due by geminidomino · · Score: 1

      ITYM "Administrative Facist."

      And actually, that was the Maniac's

      HTH.

      -GD, certified Technical Thug

  35. mv + vi by BinLadenMyHero · · Score: 0, Troll

    Try the vimv script.
    It loads a script with the mv commands in vi, let's you edit it, and then runs it.
    Very quick and straightforward to use.
    It even aligns the second column of target names, so you can use the block commands of Vim (try ctrl-shift-v then move around) to easly mass-rename files, like keeping song names in your standard (I use "style/Artist.YYYY.Album Title/NN.Song Title.ext").

  36. Why the name of the file I want to do something by hackwrench · · Score: 0, Redundant

    with of course! What you can't type a filename on your shell and have the most likely program you want to use it pop up? Reeks to be you!

  37. assign them to a short name by hackwrench · · Score: 1

    You don't do that?

    1. Re:assign them to a short name by newsblaze · · Score: 1

      Yes, lh and hog are my cshell aliases Alan.

      --
      Daily News http://newsblaze.com
    2. Re:assign them to a short name by Anonymous Coward · · Score: 0

      so you are saying he should just tell us the aliases he uses and not what the aliases actually are? that wouldn't be very informative...

    3. Re:assign them to a short name by hackwrench · · Score: 1

      so let me get this straight. you alias lh to the entire line lh ls -lt !* | head -15, and hog to the entire line hog "ps -eo pcpu,vsz,args,time | sort -rn | head -11"? or is ls and hog aliased to the rest of the line?

      BTW, My name is Robert Claypool. Is Alan a reference to Tron?

    4. Re:assign them to a short name by newsblaze · · Score: 2, Interesting

      Hello Robert.
      My name is Alan, no reference to Tron

      in my .cshrc, I have this:
      alias lh "ls -lt !* | head -15"
      alias lt "ls -lt !* | more"
      alias hog "ps -eo pcpu,vsz,args,time | sort -rn | head -11"
      alias ff "find . -name !* -print"

      I use these and many more when I'm working on the newspaper.
      You can type these aliases on the commandline if you don't want to add them to your .cshrc and it will work for just that session.

      So then I type lh in the CLI and it shows the newest 15 files - you can change that number to whatever you like.

      --
      Daily News http://newsblaze.com
  38. mine... by mrs+dogbreath · · Score: 0

    shutdown -h -now

  39. unison by buffy · · Score: 2, Interesting

    Based on the rsync protocol, unison can maintain a bi-direction file sync. I use it to sync my personal data between home and co-lo'ed server, and work and co-lo'ed server. I can update files in any of the three locations and they'll be replicated across all three.

    -buf

  40. The good 'ol... by flawedgeek · · Score: 1

    ....fsck. Fixes kernel panics in OSX 9 times out of 10.

    --
    My other Sig is .40 caliber.
  41. xargs and for loops by photon317 · · Score: 4, Informative

    There's millions of tricks, but if I had to a couple simple powerful techniques that anyone should learn that doesn't know them already, it would be xargs and commandline "for" loops.

    xargs takes whatever is piped into it, and executes a command with those things as arguments. It can do it all at once, or it can break them up in chunks, or it can execute your command once per input. Consider:

    rm -f `find . -name "*.o"`

    This normally works fine, and will forcibly remove all .o files anywhere underneath the current directory. However, if there are too many .o files to fit on a single commandline, it will barf with "argument list too long" or some such sounding error. The xargs way to do this would be:

    find . -name "*.o" | xargs -n 50 rm -f

    Which will execute a seperate "rm -f" for each chunk of 50 filenames. Take a look at the "-i" mode as well, read the whole man page. It's a great little peice of glue.

    On to for loops. You've seen them in sh/ksh/bash shellscripts like so:

    for fn in *.c
    do
        echo Sending $fn ...
        rcp $fn remotehost:/tmp/
    done

    You can of course do this straight from the commandline, which is indispensable for complex looped operations. To do it all in one line, you just have to get the semicolons in the right place. Just remember there's a semicolon before the "do", but not immediately after it:

    for fn in *.c; do echo Sending $fn ...;rcp $fn remotehost:/tmp/;done

    --
    11*43+456^2
    1. Re:xargs and for loops by photon317 · · Score: 2, Interesting


      Oh a couple more good simple ones popped into my head for beginners:

      Use "&&" between commands, and the second command will only execute if the first command succeeded. For example:

      make && make install

      That will only run the "make install" if the "make" succeeded (which is kinda contrived, since for most packages a simple "make install" would have done the same all on it's own).

      And also, did you know that you can group commands with parentheses, and you can pipe into parenthesized groups of commands? Piping into a group of commands will send the pipe data to the first command in the group that actually wants it. You can copy a directory over from one place to another using tar all in one line like so:

      tar -cf - . | (cd /otherdir/; tar -xvBpf -)

      The two tar commands are simply piping a tar-format file between them without using the disk, and the second tar runs with it's current directory set to /otherdir/.

      --
      11*43+456^2
    2. Re:xargs and for loops by Dadoo · · Score: 0, Flamebait

      Umm, no, xargs is STUPID.

      See my comment about it, above.

      --
      Sit, Ubuntu, sit. Good dog.
    3. Re:xargs and for loops by photon317 · · Score: 1


      Just because you think globbing on the commandline is stupid (and I don't neccesarily agree with you, but I haven't really thought through all the ramifications of ydoing it your way yet) doesn't make it go away. That being the environment we're dealing with on standard unix shells, xargs is a big win for dealing with that environment. Write us a new shell and a new set of the standard commandline binaries that does everything your way, or deal with the status quo like the rest of us :)

      --
      11*43+456^2
    4. Re:xargs and for loops by Minna+Kirai · · Score: 1
      The xargs way to do this would be:find . -name "*.o" | xargs -n 50 rm -f Which will execute a seperate "rm -f" for each chunk of 50 filenames.

      No, it won't. It will fail on some fairly common filenames. Someone else has already shown how intentionally created evil filenames could delete your entire disk (or at least your home directory).

      But there are more likely problems too, stemming from the use of xargs. xargs doesn't cope correctly with filenames containing " " or "-". Fortunately, there is never a need to pipe find into xargs, because find can handle everything itself. Simply use the exec option:
      find . -name \*.o -exec rm -f -- {} \;

      Alternatively, you could give a -0 option to xargs, and a -print0 option to find, for a different way to cope with a bigger range of valid filenames. But that's still not as good as find's -exec option on its own, because find can put the filenames into any part of the command, instead of only at the end.

      For example, if I want to copy all *.c files into a single directory, I can do
      mkdir ~/backup
      find . -name \*.c -exec cp {} ~/backup \;

      Is there a way to do this with xargs? I can't think of one that doesn't involve writing a separate mini-script.
    5. Re:xargs and for loops by Just+Some+Guy · · Score: 1
      But that's still not as good as find's -exec option on its own, because find can put the filenames into any part of the command, instead of only at the end.

      The main problem with that is that it fork()s once for each file it processes; "-exec rm" 100,000 files and it spawns "rm" 100,000 times. Situations like that are a huge win for xargs, since it would only spawn 100,000/n times, where n is usually much larger than 1.

      Here's how to solve your problem (safely!) with xargs:

      mkdir ~/backup
      find . -name \*.c -print0 | xargs -0 -J{} cp {} ~/backup

      The "-J{}" says "use {} as the placeholder". A quick test in my home directory generated a single 471 file long command line, which would operate much faster than executing cp 471 times.

      --
      Dewey, what part of this looks like authorities should be involved?
    6. Re:xargs and for loops by Minna+Kirai · · Score: 1

      The main problem with that is that it fork()s once for each file it processes;

      That isn't perceptible as a problem on any computer with more than 16M and 50 Mhz. Once the executable image is cached in RAM, subquesent forks seem instantaneous.

      I just made 100,000 files and tested it myself, and the find -exec rm method took under 400 ms, while xargs took just 40ms. From one perspective, 10x faster seems like a lot. But 360ms of time savings doesn't seem worth worrying about at all, especially considering how rarely a user will decide to erase 100k files.

      (I bet if my files had been of non-trivial size, or on realistically fragmented blocks, the two approaches would've taken closer to the same size, as the actual disk access for the removed files becomes significant)

      Here's how to solve your problem (safely!) with xargs:

      Not quite. To be safe, you still need to add -- after cp, to prevent hypenated filenames from being misinterpreted as options. (All the approaches I gave also need -- for the same reason. I remembered it for rm, but forgot it in the cp example)

      A quick test in my home directory generated a single 471 file long command line, which would operate much faster than executing cp 471 times.

      You are relying on the fact that these commands can accept numerous inputs at once. Many commands cannot do that (for example, archive-manipulation stuff like tar/zip). Considering finite learning time, a person who's taught my approach can apply it to a wider range of tasks- she is more likely to correctly deduce how to unpack 34 zip files.

      Additionally, my approach is easier to teach (fewer {} to learn about, no thoughts about explicitly changing string delimiters).

    7. Re:xargs and for loops by Malor · · Score: 1
      Xargs has the --replace option, which allows you to embed the argument somewhere in the middle, much like your 'find' example above. I haven't tested this (I'm not near a Unix machine right now), but from memory, this should do the same thing as your last command:
      find -print0 -name \*.c | xargs -0 --replace -n 50 cp {} ~/backup
      The --replace option tells it to substitute the arguments for {}. If you use the --replace=foo syntax, then the word 'foo' will be replaced instead. {} is the default.

      As other threads have pointed out, the -n argument lets you do fewer process spawns. If there are 100 files in a directory, it's no big deal, but if there are 100,000, then the 50x fork reduction could really matter.
    8. Re:xargs and for loops by Minna+Kirai · · Score: 0
      it's no big deal, but if there are 100,000, then the 50x fork reduction could really matter.

      In other threads, I've already reported that even with 100,000 files, spawning individual cp commands costs the user less than 1 second. A modern Unix-like can spawn repeated processes very fast- too fast to worry about, in general.

      However, in this example, that reduction doesn't even occur- nor does your suggested method even work:
      findutils-4.2.25> find -name \*.c | xargs --replace -n 50 cp {} ~/backup
      cp: copying multiple files, but last argument `./locate/locate.c' is not a directory
      Try `cp --help' for more information.
      findutils-4.2.25> find -name \*.c | xargs --replace -n 50 echo cp {} ~/backup
      cp {} /home/minna/backup ./locate/code.c ./locate/frcode.c ./locate/locate.c
      findutils-4.2.25> find -name \*.c | xargs --replace echo cp {} ~/backup
      cp ./locate/bigram.c /home/minna/backup
      cp ./locate/code.c /home/minna/backup
      cp ./locate/frcode.c /home/minna/backup
      cp ./locate/locate.c /home/minna/backup

      As other threads have pointed out, the -n argument lets you do fewer process spawns.

      Not in this case. The -n option is incompatible with --replace. Whichever one is processed last will override the other. That's why your example didn't work. Removing the -n option makes it operate correctly, but of course destroys any alleged speed benefit.

      The difficulty you (and also another poster, who wrongly suggested "-J" as an xargs option) had in getting it work is one reason I'd avoid teaching new CLI users something so difficult to get right, just because it might be faster sometimes. Correctness is much more important than speed.
    9. Re:xargs and for loops by Malor · · Score: 1

      Thank you for the correction. Normally, before I posted something like that, I'd test it to be sure it was right... but I didn't have access to a Linux machine and couldn't. That's why I included the 'untested!' warning. I don't normally use the -n command because I very rarely have situations where it would matter. I do use the --replace command with xargs all the time. That was the real reason I replied... the GGP poster thought that xargs wouldn't do the command substitution, which it will.

      One problem with using find to execute the program directly is that you have to run the find. xargs will work with any input, so you can output find to a text file, and then run xargs repeatedly on that without having to re-run the search. On most modern systems, finds run subsequent to the original will execute very, very quickly, and thus the extra overhead won't really matter, but A) not all filesystems are fast, and B) perhaps the underlying filesystem will have changed, and you need to run your later xargs on the exact same set of files, even after weeks or months have elapsed. So it strikes me that making sure people know xargs exists, even if it's not the ideal way to accomplish this specific task, may be more beneficial than teaching the EXACT right way to do it.

      Best of both worlds would probably be this thread, where both methods are demonstrated.... one incorrectly, sadly. Sorry about that.

    10. Re:xargs and for loops by pthisis · · Score: 1
      In other threads, I've already reported that even with 100,000 files, spawning individual cp commands costs the user less than 1 second.

      Not even close to true here. Linux 2.6, up-to-date Fedora distro, 1 Ghz P3.
      $ ls | wc -l
      1931
      $ time find . -name '*' -exec /bin/echo {} \; > /dev/null
      real 0m2.346s
      user 0m0.561s
      sys 0m1.729s
      $ time find . -name '*' -print0 |xargs -0 /bin/echo > /dev/null
      real 0m0.061s
      user 0m0.010s
      sys 0m0.019s
      That's 2.3 seconds slower for just under 2000 files.
      --
      rage, rage against the dying of the light
    11. Re:xargs and for loops by Anonymous Coward · · Score: 0

      You can copy a directory over from one place to another using tar all in one line like so:

      tar -cf - . | (cd /otherdir/; tar -xvBpf -)


      Very nice. I can't help but think that cp -r is a little simpler, though... :P

    12. Re:xargs and for loops by Ikn · · Score: 1

      Interesting; I'm a big-time UNIX/command line newbie, so this is enlightening to me! Is this because of the 'short circuit' way C++ evaluates boolean expressions / does this stem from the fact that UNIX was written in C?

      --
      I know nothing
    13. Re:xargs and for loops by scotch · · Score: 1

      Your test likely shows caching effects for the second run.

      --
      XML causes global warming.
    14. Re:xargs and for loops by pthisis · · Score: 1

      I ran both commands many times. It's perfectly repeatable, and the results don't vary based on the run order.

      --
      rage, rage against the dying of the light
    15. Re:xargs and for loops by scotch · · Score: 1

      My bad. I actually disagree with the guy you were replying to - frequently you can't discount the system() overhead that you get with the -exec option to find. xargs is very useful. Apologies and nice rebuttal to said guy.

      --
      XML causes global warming.
  42. Xyzzy by poena.dare · · Score: 1

    Xyzzy was absolutely necessary and I used it every day from 1979 to 1984. Then I bought a Mac and my life went to hell.

  43. Going waaaaay back here ... by rpresser · · Score: 1

    ]PR#6

    1. Re:Going waaaaay back here ... by tekiegreg · · Score: 1

      Sad part is I do remember what that is, long live the Apple II.

      --
      ...in bed
    2. Re:Going waaaaay back here ... by MarkRose · · Score: 1

      I always liked sticking the printer in slot 6, just to mess people up.

      Of course, by the time I finally got rid of that old machine, I had flopply controllers in slots 6, 5, and 4. ProDOS made handling multiple disks a breeze. Printers were on 7 and 1 (one for labels, the other for regular), mouse on 2, and a 64 KB RAM expansion :D

      --
      Be relentless!
    3. Re:Going waaaaay back here ... by lrucker · · Score: 1

      POKE 33,33

  44. To add to all the others by Will2k_is_here · · Score: 1

    I really like:
    du -sh *
    Probably best to put this in your .bash_profile file (or equivilant):
    alias diskusage=`du -sh * && du -sh .[A-Za-z]*`
    (I know this can be shortened with regular expressions, but I've never looked into it)

    Anyway, if need be, pipe that to a "sort"-on-steroids and you can see where your disk space is getting eaten up.

    1. Re:To add to all the others by ChrisJones · · Score: 1

      I like:

      du -h --max-depth=1 /data/

      for profiling disk usage quickly :)

      --
      Chris "Ng" Jones
      cmsj@tenshu.net
      www.tenshu.net
    2. Re:To add to all the others by Anonymous+Crowhead · · Score: 1

      I have this in my .bashrc:

      alias d1='sudo du --max-depth=1'

      That way, as my non root admin user, I can quikly see the disk space usage no matter where I am.

  45. fastest shutdown or restart command for Linux by Tumbleweed · · Score: 1

    From my painfully extensive man page research years ago, this seems to be the fastest way to (safely) shutdown (or restart) a Linux box:

    shutdown -hn now (for halt)
    shutdown -rn now (for restart)

    I call this my "Express Elevator to Hell: System Goin' DOWN!" command. [Somebody wake up Hicks.]

    1. Re:fastest shutdown or restart command for Linux by qualico · · Score: 1

      How about these?

      reboot

      or

      CTRL+ALT+DEL

    2. Re:fastest shutdown or restart command for Linux by orkysoft · · Score: 1

      Instead of typing "now", you can save two keystrokes by typing a zero ("0") instead.

      --

      I suffer from attention surplus disorder.
    3. Re:fastest shutdown or restart command for Linux by Miniluv · · Score: 1

      You can save quite a few more since virtually every linux system today supports halt and reboot as aliases to the relevant shutdown strings. I myself find it significantly more meaningful to type halt rather than shutdown -h, and especially so with reboot versus shutdown -r.

    4. Re:fastest shutdown or restart command for Linux by orkysoft · · Score: 1

      I know that, I type halt and reboot myself too, nowadays. It's a lot faster than the point-n-click method of shutting down the system ;-)

      --

      I suffer from attention surplus disorder.
    5. Re:fastest shutdown or restart command for Linux by DRACO- · · Score: 1

      I prefer the init.conf setting for alt control delete while on console..

      I switched it from reboot to shutdown. Just flip to a console and hit alt control delte. If I really need a reboot I could just hit alt control delete again right before the system turns off.

      --
      Consider yourself blessed if you are sneezed on by a dragon and only get wet, it could have been a fireball.
  46. find ... -exec ... \; by J'raxis · · Score: 1
    Isn't that searching the files for "bar", not merely matching their names? But you don't really need xargs to do that either, you can do something like:

    find . -name '*.ext' -exec grep -i bar {} /dev/null \;

    1. Re:find ... -exec ... \; by FreeForm+Response · · Score: 1

      Isn't that searching the files for "bar", not merely matching their names?

      I think it searches in the file names only, since the "-name" option was specified.

    2. Re:find ... -exec ... \; by J'raxis · · Score: 1
      The original example, I meant. It was:

      find . -name '*.ext' |xargs grep -i bar

      This is passing all files named *.ext to grep via xargs; the contents of said files are then searched by grep for "bar". The comment I replied to was someone's attempt at optimization which inadvertantly changed what the command actually did.

    3. Re:find ... -exec ... \; by FreeForm+Response · · Score: 1

      You're right; I misread the comment chain. I apologize.

  47. aliases with g and w suffixes by tldraben · · Score: 1

    I create aliases with a "g" suffix to grep the results and an "w" suffix to "which" the 1st argument for commands that I commonly grep or which. For tcsh, some examples are:

    alias hg history \| grep \!^
    alias envg env \| grep \!^

    alias lsw ls -l \`which \!^\`
    alias viw vim \`which \!^\`
    alias llw ls -l \`which \!^\`

    Another set of useful aliases to use the directory stack:

    alias bk popd
    alias cd pushd
    alias d dirs -v
    alias godir pushd +\!^
    alias go pushd +\!^

    And the most commonly executed alias to list the 10 most recent files in dir:

    alias lst 'ls -1t \!* | head -10'

  48. There are a few, I guess by kwerle · · Score: 1

    ssh is awesome. ssh -L, keys, encryption, compression. Awesome.
    sort -n
    grep is an amazing tool.

  49. su,rz,sz,cu,dd,cat,tar,cut,vi,w,wget,lf,bc,tee,man by qualico · · Score: 1

    "su", Love to be on top. :->

    Here are a couple no one has mentioned yet.
    "rz" and "sz"
    It's the shell equiv to receive and send via zmodem.
    Works great when moving files from a terminal emulator like kermit.

    "dd" is great for disk clone and backup.
    "cat" is my quick output judo chop
    "tar -xvzf" for dealing with sources

    "cut" gotta say I've replaced a lot of sed and awk code with this simple string manipulator.

    "vi" I want a vi T-shirt, how nerdy is that?

    "w" gotta know whos on first, whats on...

    "wget" is sweet for downloading

    "lf -la" to search for hidden files. Anyone seen ".. "? {notice the space.)

    "bc" for calcs

    "tee" for splitting processes

    "man" Since I can't fit anymore on the subject line, I'll finish with this one I'm sure everyone has used.

    If you could master everything on the following man page, give yourself a pat on the back...you are one powerful tech.
    "man perlre"

  50. make yourself a few aliases by frn123 · · Score: 2, Informative

    Need to find that file named somethingfoosomeotherthing?
    alias ff='find . |grep -i '
    >ff foo

    ./somedir/somethingfoo
    ./somedir/something foo2
    ./somedir/somethingfoo3

    Need to find that pesky configuration file for printer?
    ~/bin/gr:
    grep -i -r $1

    ~/bin/fgre:
    grep -i -r -l $1

    >cd /etc/
    >fgr laserjet

    ./cups/ppd/hp.ppd:*ShortNickName: "HP LaserJet Series"

    Just interested which files to check?
    >fgre laserjet

    ./cups/ppd/hp.ppd

  51. Midnight Commander. by Inoshiro · · Score: 2, Interesting

    'mc' is your gateway to a much more powerful shell. Combine your command line shell with quick changing to bookmarked dirs (ctrl+\); easy adding to that via alt+a; F2 menus that let you easily compress subdirs, or run other things from your actions file based on the mime-type or file pattern; two-panes at two different FS locations; undelete FS, FTPFS, and other meta-FS interfaces; good mouse support; built-in editor (Cool edit); prompts you for arguments for makefiles you hit enter on...

    The list goes on. Midnight Commander is a shell designed to speed up all your common tasks. It has sane defaults you don't really have to change much. It'll make you more productive!

    --
    --
    Internet Explorer (n): Another bug -- that is, a feature that can't be turned off -- in Windows.
    1. Re:Midnight Commander. by Anonymous Coward · · Score: 0

      What he said!

    2. Re:Midnight Commander. by fuzza · · Score: 2, Informative

      Not to mention, it's really useful for temporary (ie. until you can reinstall) cleanups of compromised systems, since (a) it uses its own internal code for things like ls, chmod, etc, and (b) rootkits don't generally replace it :)

      --
      Can't find examples of evolution? No matter, neither could Dawkins
  52. My favourites by cowbutt · · Score: 2, Informative

    strace/truss/ktrace for Linux, Solaris and BSD/MacOS respectively. If a program fails to start, or terminates abnormally, this will usually give me the heads up on why (it's usually a missing file, or bad permissions) without having to break out gdb.

    lsof. Useful in so many ways; for debugging situations similar to the above, as well as hardening systems and building chroot environments for specific programs.

    tcpdump/snoop/tethereal/ethereal. If you can see what's really on the wire between two network applications, you can probably figure out what's going wrong. Ethereal is particularly nice.

    hexdump/khexedit. If you can see what's really in the file used by an application, you can probably figure out what's going wrong. :-) khexedit also has a bonus feature of being able to perform statistical logical operations across the file; useful if you have a file which you suspect has been encrypted with some lame substitution cipher.

    After those, the usual - sed, awk, grep, find. It's rare that I can't turn any problem into an awk-shaped nail. :-)

    1. Re:My favourites by cowbutt · · Score: 1
      Moderation -1 100% Troll

      Troll? WTF?!

  53. Buh? by willfe · · Score: 1

    How about:

    $ find /wherever -maxdepth 1 -exec du -sm {} \; | sort -n

    Replace "-sm" with "-sk" if you want kilobytes instead of megabytes. Total space consumed by the named directory appears at the bottom of the list.

    --
    Read my stuff.
    1. Re:Buh? by ChrisJones · · Score: 1

      How about just using du's --max-depth option? ;)

      --
      Chris "Ng" Jones
      cmsj@tenshu.net
      www.tenshu.net
    2. Re:Buh? by RGRistroph · · Score: 1

      The dusort shell function that I use may pre-date the max depth option to du. I copied my current set of dotfiles and window manager settings from a co-worked in 1997, and I have made only minor modifications since.

      There used to be dozens of find/grep aliases to make a recursive grep, untile they wrote rgrep and then added the -r flag to grep.

  54. ssh is a pipe, too (from linux.com) by ChipMonk · · Score: 1

    If you want to copy a directory hierarchy from the local system to a remote:

    tar cf - * | ssh user@system " cd ; tar xvf - "

    Conversely, from remote to local:

    ( ssh user@system " cd ; tar cf - * " ) | ( cd ; tar xvf - )

    Add a "-C" to the ssh commands for compression.

    1. Re:ssh is a pipe, too (from linux.com) by kwerle · · Score: 1

      rsync is now smart and uses ssh.

      But I've certainly used the tar over ssh method a few times, and I will be using it again soon for a nightly build install to a remote machine (cat tarball | (ssh rmachine tar -C / -x -f -))

    2. Re:ssh is a pipe, too (from linux.com) by j-pimp · · Score: 1
      tar cf - * | ssh user@system " cd ; tar xvf - "


      Well dont forget about -p option. Sometimes I want to clone whole machine. The target lacks entries for the uids in /etc/passwd so -p preserves them. I boot it up with the redhat rescue disk or knoppix, setup my desired mounting scheme within /mnt/sysimage and do:
      tar -czf - / | ssh user@system " tar -C /mnt/sysimage -xzpf - "


      After this edit fstab, and get the kernel to boot your system.
      --
      --- Justin Dearing http://www.justaprogrammer.net/ We're just programmers.
  55. abcde by jb.hl.com · · Score: 1

    abcde, a better cd encoder. So great it's untrue. Try it, you might love it.

    --
    By summer it was all gone...now shesmovedon. --
  56. Aieeeee! by samael · · Score: 1

    We all have our CLI amor

    No, no we don't.

  57. Deleting files with untypable characters by dschuetz · · Score: 1

    Back in school, our Pascal compiler often would dump files in the current directory with garbage filenames, with lots of special characters in 'em so you couldn't type them at the shell (or use shell expansion, either). Someone showed me a trick that I still use to this day:

    ls -i
    find . -inum inode -exec rm -i {} \;

    The ls -i gives you the inodes for all the files in the current directory. Find the inode for the file you can't delete, then use that in the find command to actually select it and delete it with the -exec call (or rename it or whatever else you want to do with it).

    I don't need it as much lately, but it's still occasionally useful. Files with a leading "-" often give me fits, for example...

    1. Re:Deleting files with untypable characters by DrSkwid · · Score: 1

      nice one, i needed that

      here's one back a ya
        Files with a leading "-" often give me fits, for example...

      ls -- -*

      -- generally 'means no more args'

      --
      There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
    2. Re:Deleting files with untypable characters by Anonymous Coward · · Score: 0

      ls ./-*

      Works for programs that don't support --.

  58. perl one-liners ~= sed by Anonymous Coward · · Score: 0

    I love that so many people are resonding with "perl" and then giving a sed example. Learn your roots. If you're using perl to do nothing more sophisticated than what can be done with sed, why not use sed? I don't get it.

  59. scp is your friend by DrSkwid · · Score: 2, Informative


    scp -C -r * user@system:target

    and

    scp -C -r 'user@system:/target/*' .

    --
    There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
    1. Re:scp is your friend by Linux_Bastard · · Score: 1

      Be carefull with the -C, with compressed files, your just burning CPU,
      Also,

      rsync -avz -rsh="ssh" * user@system:target

      works especially well for pushing updates.
      For faster, lower security (protected internal network)
      you can add "-1" to the ssh
      i.e. rsync -avz -rsh="ssh -1" * user@system:target

      I usualy alias rcp to rsync -avz -rsh="ssh"
      (mostly because of the alarm that seeing 'rcp" in the history gives to the other sysadmins)

      --
      F X=0:1:9999 F D=2:1 Q:((X>2)&(X#D=0)!((D>X/2)&(X'=1))) I D>(X/2) W:$X>75 ! W X,?$X+5-$l(X) Q
  60. I can't believe no one mentioned it... by gabe · · Score: 1

    fart !

    --
    Gabriel Ricard
  61. He,He.... by StealthEMD · · Score: 0

    Rm -Rd C:\windows or the little known Purge

    --
    IT Specialist - Nottawaseppi Huron Band of Potawatomi Indians
  62. win.com by Anonymous Coward · · Score: 0

    's all I need.

  63. Ultimative CLI util in the Win32 world... by Hymer · · Score: 1

    ...is RoboCopy
    It copies anything anywhere including security info (if needed)... locally or over the lan.
    It will not copy similar files unless it is forced to do it.
    It will wait for "mount", it will retry on failure.
    ...and it is able to make a mirror of a directory...
    RoboCopy is THE best CLI utility provided by MSFT, it is a part of the Resource Kit for Win NT4 and W2K...

    Another cool utility from the W2K Resource Kit is NETSVC. It is a remote NET command.

    No I'm not a MSFT fanboy... I just like those two utils...

  64. ZTree and UnixTree by Glonoinha · · Score: 3, Interesting

    Yea, Though I compute through the user interface of the shadow of death, I shall fear no evil, for ZTree is with me.

    No joke - ZTree is a character for character re-write of an old utility called XTree Gold v2.0 or 2.5 - and it is by far the most effective and influential interface between me and my data. The entire file system is but an extension of my mental processes, and I can slice and dice through the multi-dimensional (time, space, attributes, multi-layered directory structure, multi-drive architecture,) in effect creating a virtual directory within which I control the parameters driving what is listed, in what order - then copy, view, move, delete, diff (file compare), view in hex mode (and edit it in hex mode), search for text in lists of files, compare directory trees for like or different files (binary, time stamp, etc.)

    It is totally CUI, about like Midnight commander but a ton better. Take time to get fluent in ZTree (UnixTree for Unix / Linux, a bit older with a few quirks, but still pretty damn good) and you will be like the guys in the Matrix sitting at their green screen terminals.

    ZTree Don't leave $HOME without it.

    --
    Glonoinha the MebiByte Slayer
    1. Re:ZTree and UnixTree by rduke15 · · Score: 1

      ZTree Don't leave $HOME without it.

      Well, it seems that would be don't leave %USERPROFILE% without it, since it's only for Windows (and OS/2).

      And if it's Windows, Total Commander seems to be much better. I wish Midnight Commander would be as good and feature rich as Total Commander. And I wish there was a Mac version.

    2. Re:ZTree and UnixTree by Glonoinha · · Score: 2, Interesting

      Ya - there is a Unix version too (not from the same guys, but following the same exactly layout.)

      And I got excited about TC - but alas it is mouse clicky centric. ZTree was designed and implemted to be 100% character based (although I guess you could use the mouse, I haven't actually tried.)

      When you can use TC to find the files located somewhere on your hard drive, directory unknown, name unknown, extension unknown, dated somewhere around Christmas of 2003, containing the phrase 'Total Commander' but not containing the phrase 'Midnight Commander', sized between 50k and 53k, excluding .dll, .exe, .js and .html files, including files that are flagged system or hidden but excluding files that are flagged 'system and hidden and read-only', and then create a text file with a list of the full path/name.ext of all the files sorted reverse chronologically - without touching the mouse - in under 20 seconds - and then copy all of those files yet only those files (twice, one including directory structures, and again just dumping all of them into some new directory) to another hard drive ... then I will give it another look, maybe even drop ZTree / UnixTree (which run from the command line / command prompt / korn shell w/o a need for any GUI or mouse) for it. Until then, it looks cool, but I'm going to keep on recommending my CUI.

      --
      Glonoinha the MebiByte Slayer
    3. Re:ZTree and UnixTree by csirac · · Score: 1
      ZTree Don't leave $HOME without it.

      Well, it seems that would be don't leave %USERPROFILE% without it, since it's only for Windows (and OS/2).


      Hmm, perhaps he/she meant ytree: http://packages.debian.org/unstable/utils/ytree
  65. The problem with perl... by Anonymous Coward · · Score: 0

    .. is that it leads to perl-syndrome.

    Q: "How do you do X"?

    perl-syndrome A: "oh, easy, I'll just spend 5 minutes whipping up a perl one-liner!"

    normal A: "You use the command sed"

  66. You are frickin' insane. by Just+Some+Guy · · Score: 4, Insightful
    find . -name "*.o" | xargs -n 50 rm -f

    That's great. Now, create a directory called " " (empty space). Inside that, create a directory called " -rf " ("-rf" with an empty space on either side). Inside that, create a file named " " (yet another empty space). Now, watch in horror as find prints "./ -rf /", which it passes dutifully to "rm -f". Since xargs by default passes each word as an individual argument, that expands to:

    rm -f ./ -rf /

    Hope you weren't running as root! The moral of this story is to never, never! use find/xargs without the "-print0" option whenever the command you're executing is destructive. "ls" is probably OK. "rm" definitely isn't.

    --
    Dewey, what part of this looks like authorities should be involved?
    1. Re:You are frickin' insane. by smallfries · · Score: 1

      Ok, I had a look at this because I couldn't see what you meant at first. You still need something.o inside that fairly particular tree to cause damage. But assuming that for some reason there is an evil tree in your file system you still just need to protect the input. Quick look at the manpage came up with this:

      find . -name '*.o' | xargs -i{} echo \"{}\"

      Obviously I just tested it with echo as I don't have a disposible filesystem but it appeared to work...

      --
      Slashdot: where don knuth is an idiot because he cant grasp the awesome power of php
    2. Re:You are frickin' insane. by prefect42 · · Score: 1

      So just fix the last part no?

      find . -name "*.o" | xargs -n 50 rm -f --

      --

      jh

  67. screen by The+Rizz · · Score: 1

    I still have to love the screen program. It's one of the most useful programs I've ever seen, especially if you have to remotely connect to said system. Teminal multiplexing, ability to "detach" screens in one location and "reattach" them elsewhere (such as when you login from another physical location), allow you to splitscreen, etc. etc. Also is VERY handy if you're connecting over an unreliable connection (such as a modem) - if your connection drops, you can reconnect, do a screen -r, and you're right where you left off - the program never even stops running.

    My other useful command (in my .bash_profile):
    alias cls='clear ; w -fs ; echo ; free ; echo ; df -hT ; echo'
    This gives me the vital system information with one command.

  68. what scp won't do by ChipMonk · · Score: 1
    1. If scp is not large-filesystem aware, then you will be restricted to files under 4G.
    2. You can make remote backups to local devices, like tape: ssh root@remote "tar cf - src-dir" >/dev/st0
      Even rsync won't handle that.
  69. My favourite command has to be... by Anonymous Coward · · Score: 1

    ... "net". Net use, net view, net stop, net start, the possibilities are virtually endless. And it's not foolproof, a fact that certainly contributes to my bias.

  70. A couple of tricks by jregel · · Score: 1

    Some of the useful shortcuts I use a lot:

    To display the size of all subdirectories in the current working directory, sorted by size:

    du -sk * | sort -nr

    In bash, a very useful feature is the ability to reference the last parameter of the previous command line using !$

    For example:

    # mkdir /a/very/long/directory/pathname
    # cd !$

    The shell will expand the second command to:

    # cd /a/very/long/directory/pathname

    Running subshells from within programs like vi and ftp using the ! command (e.g., !ls in ftp).

    Someone else has already commented on ^r in bash to reverse search through the history.

    Not Unix, but on Windows, tcpview and process explorer (both available from sysinternals) are invaluable.

  71. Favourite commands by Tinned_Tuna · · Score: 1

    I am lost here, is it just me (I haven't read allll the posts yet), but why has nobody mentioned gcc??? am I in my own little world here?

  72. ls without the permissions? by Minna+Kirai · · Score: 1

    Question for ls-adjusters: How can I stop ls -l from printing a column of -rw-r--r--, which is rarely very interesting (few people spend much time dealing with files whose permissions are interestingly mixed).

    I usually run "ls -log", which gives me filesize and date (that I want) but removes owner and group (which I almost never want). But I still can't take off the permissions column without something like "ls -log | cut -c 14-", which seems excessive.

  73. Two invaluable guides: by Burz · · Score: 1
    The first is more of a tutorial, LinuxCommand.org:




    The Linux Cookbook had a free release before the 2nd edition came out.

  74. Grossest commands... by Anonymous Coward · · Score: 1, Funny

    Personally, I like head. And getting tail is always fun. Of course, the classic sequence is:

    unzip ; strip ; touch ; nice ; finger ; grep; mount ; fsck ; more; yes ; umount ; make clean ; sleep ; dump

  75. I love the SELECT command... by Richard+Steiner · · Score: 2, Interesting

    ...but it's limited to JP Software shells (4DOS, 4NT, 4OS2), and the authors of Linux shells don't seem interested in implementing it.

    SELECT is a command which provides a fullscreen point-and-shoot file selection interface for other commands, allowing for the easy arbitrary selection of target files (point-and-shoot) in command aliases or batch/script files. In essence, it provides a mini filemanager interface which can be used to select the targets for *any* command on the command line, used in aliases, etc.

    Some simple examples (from my 4OS2 alias file) are as follows:

    TCOPY=select copy (*.*) %1
    TMOVE=select move (*.*) %1
    TDEL=select del (*.*)
    TRUN=select %1 (*.*)
    TEDIT=trun fte
    TLIST=trun list
    UNZ=f:\unz.cmd
    TUNZ=select unz (*.zip)

    The filespec in parenthesis limits the files which appear in the selection list, so the TUNZ command will only show .ZIP files as potential targets.

    --
    Mainframe/UNIX Bit Twiddler and long time Windows/Linux Hobbyist.
    The Theorem Theorem: If If, Then Then.
  76. Copy whole file trees, even btween nodes by Phreakiture · · Score: 1

    tar -cf - . | (cd $destination;tar -xvf -)

    tar -cf - . | ssh $user@$host "(cd $destination;tar -cvf -)"

    --
    www.wavefront-av.com
  77. not too exotic by hyperstation · · Score: 1

    but scp and cat are probably my fav tools, i use them every day

  78. DIR by MooseTick · · Score: 1

    I like DIR. It tells me what files are in a directory. That frees me from having to memorize where are the files are on my computer. That used to make me real tired and my head hurt.

  79. Suicide Command... by PhoenixDragon0 · · Score: 1

    rm -rf /

  80. xargs and spaces by DragonHawk · · Score: 1

    "Just use -exec. It's slower, but easier and you don't have to fight with line-endings, spaces in the filenames, and stupid cli arg limitations."

    find parameters -print0 | xargs -0 command

    I use that all the time. The -print0/-0 stuff causes find and xargs to use NUL-terminated strings.

    I've run into CLI length limits maybe twice in the past five years. If you do hit it, "xargs -s n", where "n" is the maximum number of characters in a command on your system, will work around it. Alias that in and you'll never have to type it again.

    --

    dragonhawk@iname.microsoft.com
    I do not like Microsoft. Remove them from my email address.
    1. Re:xargs and spaces by sudog · · Score: 1

      ... or you can just use -exec, and you don't *ever* have to worry about CLI arg limitations.

      *shrug* If you want to be bitten by a bizarre CLI arg limitation every few years (which makes it just that much harder to track down) be my guest. I'll stick with -exec and never--ever--have to worry about the problem. Even once.

    2. Re:xargs and spaces by DragonHawk · · Score: 1

      "If you want to be bitten by a bizarre CLI arg limitation every few years (which makes it just that much harder to track down) be my guest."

      You make a good point there.

      Still, for myself, I've had to worry about the limitations of find ... -exec more often then I've had to worry about the limitations on the shell's command line length. The overhead for fork'ing for each found file can be a killer -- for me, it has made the difference between minutes and hours. If I hit the CL length limit often enough, I'd probabbly add "alias xargs='xargs -n limit'" to my ~/.bashrc or something.

      Other people (such as yourself) will have different needs, of course.

      Regards,

      --

      dragonhawk@iname.microsoft.com
      I do not like Microsoft. Remove them from my email address.
  81. xargs and resources by DragonHawk · · Score: 1

    "A modern Unix-like can spawn repeated processes very fast- too fast to worry about, in general."

    All blanket statements are false.

    I find that process-spawn overhead can still be important, especially when you're dealing with large data sets or non-trivial processing. It can mean the difference between minutes and hours of processing.

    As far as your arguments about "finite learning time" go, I think you're overstating the brain drain something like "xargs" introduces. It isn't like we're learning a new programming language; I think there is room for both, here, and both are useful tools.

    --

    dragonhawk@iname.microsoft.com
    I do not like Microsoft. Remove them from my email address.
  82. Apple ][ Lore by DragonHawk · · Score: 1

    POKE 33,33

    What's that do? I remember the first one (PRint to card in slot 6), but don't remember that POKE.

    Ahhh, PEEK and POKE. CALL. BLOAD. What fun.

    --

    dragonhawk@iname.microsoft.com
    I do not like Microsoft. Remove them from my email address.
    1. Re:Apple ][ Lore by lrucker · · Score: 1

      Sets the screen width to 33 instead of 40, so that when you do a source code listing there's no extra space inserted for indents, so you can use the cursor keys to move up and edit the lines.