
Some Unix Tricks - kirubakaran
http://blog.transmit.net/2008/10/my-best-unix-tricks.html
======
mkn
_If you ever do end up with me interviewing you, I'll likely work one or two
of these into the discussion to explore your level of knowledge about Unix._

Translation:

If you ever do end up with me interviewing you, I'll likely work one or two
obscure questions into the discussion to make you feel stupid so that I can
gloat. That's how charming I am.

~~~
alecco
When you face that situation, never answer it properly because it will
probably piss him off! Answer something close to OK. Praise his skills when he
enlightens you with his "right" answer. That will get you the job, if you
still want to suffer working for him.

After the second tip I was expecting

echo $PASSWORD | compress -f > /etc/password

------
silentbicycle
A good way to learn this sort of stuff is:

    
    
      for util in `ls $DIRNAME`; do whatis $util; done
    

where DIRNAME is /bin /sbin /usr/bin /usr/local/bin etc. depending on what
Unix you're running.

Pick a couple that interest you and check out their man pages. Or, follow the
_SEE ALSO_ section in man pages.

------
staunch
For "Remove DOS ^M from ends of lines" most Linux distros (at least) have
unix2dos and dos2unix.

    
    
        $ printf "test\r\n" > test.txt
        $ cat -A test.txt 
          test^M$
        $ dos2unix test.txt 
          dos2unix: converting file test.txt to UNIX format ...
        $ cat -A test.txt 
          test$

~~~
sant0sk1
if not in your Debian path:

    
    
        apt-get install tofrodos

------
astine
Well, I knew #4, and I could have figured out the rest if I needed to, but
still, good to know.

I'm always surprised at how much of Unix's default command set is oriented
towards text manipulation. People always argue between Vim and Emacs. I wonder
if anyone's ever compared Emacs and Bash.

~~~
silentbicycle
It's not a meaningful comparison because it's not an either/or. You can use
said shell commands inside Emacs pretty easily: M-| is shell-command-on-
region, with output to another buffer, and univ. argument M-| replaces the
region with the command's output. Same with vi, for that matter: :1,10!sort
pipes the first ten lines of file through sort, for example. vi has ex mode,
all the commands starting with ":". Ex is basically an embedded sed.)

2\. None of the shell command stuff is tied to bash -- you can use any of them
with sh, ksh, zsh, etc.

~~~
astine
It doesn't have to be an either/or for the comparison to be meaningful. As to
the specicifity to Bash, I could have substituted 'shell' or Unix environment
just the same and meant the same question, that is, the advantages of working
within Emacs or Vim, versus do the same operations directly from the command
prompt.

~~~
silentbicycle
I usually run the command prompt inside Emacs, anyway -- it's another big text
buffer to edit / copy from.

