Classical Tools


Table of Contents

often used commands 
expr 
cmd:echo 
cmd:trap 
cmd:sleep 
cmd:rm 
cmd:pidof 
cmd:dircmp 
cmd:script 
cmd:most 
cmd:cp — copy a directory structure 
Usage 
Version control 
Help 
cmd:basename 
to remove any extension 
cmd:dirname 
Usage 
cmd:less 
what's a good text/binary file viewer? 
cmd:top 
SORTING of task window 
SORTING of task window 
ls sort order 
ls sort order 
ls sort order again 
ls sort order again 
3 lines to 1 line ? Help Please 
3 lines to 1 line ? Help Please 
3 lines to 1 line ? Help Please 
3 lines to 1 line ? Help Please 
3 lines to 1 line ? Help Please 
cmd:paste 
paste -sd 
file date format 
file date format 
Can u help this simple Unix Pattern Match 
Can u help this simple Unix Pattern Match 
cut 
merge two text files in unix 
reverses the text 
flip 
tail 
cmd:screen 
Usage 
cut and paste with the screen program 
freeze rows in terminal screen 
cmd:touch 
Usage 
Help 
change file time in selected directories 
Usage 
Help 
Trying History 
Link's time can't be changed! 
Command:touch and irregular file names 
cmd:tr 
removing CR-LF with tr 
Usage 
Limitation 
cmd:kill 
cmd:kill 
cmd:kill 
Stop/suspend, then resume with cmd:kill 
cmd:su 
problem 
Usage 
Help 
cmd:sort 
Usage 
Help 
Fields & blanks 
Any way to sort this? 
Perl solution: 
gnu sort, field selection bug? 
gnu sort, field selection bug? 
cmd:join 
Help 
Problem with command 'join' 
Hardlinks 

often used commands 

cmd:echo 

/bin/echo —help Usage: /bin/echo [OPTION]… [STRING]… Echo the STRING(s) to standard output.

-n             do not output the trailing newline
-e             enable interpretation of backslash escapes
-E             disable interpretation of backslash escapes (default)
    --help     display this help and exit

cmd:trap 

Normal usage 

tmpf=tmp.$$
trap "rm -f $tmpf" 0
trap "exit 2" SIGHUP SIGINT SIGQUIT SIGTERM  # 1 2 3 15
cat > $tmpf
cat $tmpf ..

Manipulating 

Trap set & show:

$ trap -p
$ trap 'rm semaphore' 0
$ trap 'rm semaphore' SIGINT
$ trap -p
trap -- 'rm semaphore' EXIT
trap -- 'rm semaphore' SIGINT
$ trap -l
 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL
[..]
$ set -x

Press ^C:

$ ++ rm semaphore
rm: cannot lstat `semaphore': No such file or directory

Trap reset:

$ trap - SIGINT
+ trap - SIGINT

Press ^C again, no more traps:

$

cmd:sleep 

Usage 

In unix:

sleep 10

sleep 10 seconds

To execute a command after a certain amount of time:

(sleep 105; command)&
[Note]

sendf can't use this way (when user interaction is needed). Put it in foreground instead.

Linux special 

sleep 2m

sleep 2 minutes

SUFFIX m for minutes, h for hours or d for days.

cmd:rm 

-r Recursively remove directories and subdirectories in the argument list. -f Remove all files (whether write-protected or not) in a directory without prompting the user.

cmd:pidof 

$ pidof emacs
1795 1506 1495
$ [ `/sbin/pidof nono` ] && echo aaa
$ [ `/sbin/pidof X` ] && echo aaa
aaa

cmd:dircmp 

*Tags*: dir compare. compare directory.

cmd:script 

script [-a] [-c COMMAND] [file]

For single command, you can use

script -c COMMAND
-c COMMAND
        Run the COMMAND rather than an interactive shell.  This makes it
        easy for a script to capture the output of a program that behaves
        differently when its stdout is not a tty.

cmd:most 

Info 

most - browse or page through a text file

Usage 

most -ct4 +82 keymap.c

makes searches case sensitive, sets tabwidth to 4, and displays the file keymap.c starting at line 82.

Help 

MOST version S4.8.1 Usage:
most [-1bckstvw] [+/string] [+line number] [+s] [+d] file...
where: -1:  assume VT100 terminal. (VMS only)
       -b:  Startup in binary mode.
       -c:  Make searches case sensitive.
       -k:  Kanji mode.
       -s:  Squeeze out excess blank lines.
       -t:  Display tabs as ^I.  If this option is immediately followed
              by an integer, the integer sets the tab width.
       -v:  Do not interpret backspace formatting characters.
       -w:  Wrap lines.
       -z:  No gunzip-on-the-fly.
       +/string:
            Search for string
       +line number
            Start up at specified line number.
       +d:  Allow file deletion.
       +s:  Secure Mode-- no edit, cd, shell, and reading files not
              already listed on the command line.