Infolinks

Wednesday 6 June 2012

Unix Commands

Unix Commands


Unix Commands


Unix Commands
cal - Calendar 2000
who - Who is logged on
finger - Details of logged on users
write - To send messages to users
Ctrl+D - End of file
mesg n - To deny talking
mesg - To know the status
Man - Help command
cat - Display multiple files.
clear - Clear screen.
Date - Displays the system date.
cd - Change directories.
chmod - Change security mode of a file or directory.
cp - copy files from one directory to another.
mv - Move or rename files.
cut - Select and extract columns or fields from a file.
echo - Display the specified Arguments on the output device.
find - Locate a file which meet the search criteria.
grep - Select lines or rows that match a specified pattern.
kill - End a process.
ln - Creates link directories between files,thereby allowing more than one name for a file.
lp - Print a file.
ls - lists a directory’s contents, including its files and subdirectories
mkdir<.span> - Make a new directory.
>span style="color: red; font-family: Verdana, sans-serif; font-size: 10pt;">passwd - Change your Unix password.
pwd - Display your current path.
rm - Remove a file
rmdir - Remove a directory
sh - Execute a shell script.
sort - Sort and merge multiple files.
trap - Executes a command when a specified signal is received from the operating system.
Type cd and press enter to make sure you are in your home directory.
mkdir to make a new directory
ls to see the contents in your directory.
ll to see the contents in your directory.
cat to create a new file.
ctrl + z to save the file.
Login process:
Login: xxxxx
Password: ******
# -->System administrator prompt
$ -->User working prompt
Basic commands
1. Log name -it displays the current user name
2. $Pwd --it displays current working directory
3 $Clear --it clear the screen
4. $Exit – to logout from current user
5. $Date – it displays system date and time
Sat mar 4 04:40:10 IST 2005
6. $Who am I – it displays current user name, terminal number, date and time at which
You logged into the system
Tec no ty01 mar 4 09:30
7. $Who –To displays the information about all the users who have logged into the system
Currently. I.e., each user login name, terminal number, date and time when the
Person logged in
Tecno1 tty01 mar 4 09:30
Tecno2 tty05 mar 4 10:10
Tecno3 tty06 mar 4 10:15
i.e. Tecno1 – log name
Tty01 - terminal name
Mar 4 - date
09:30 -time
8. $Finger – it displays complete information about all the users who are logged in
9. $Cal – it displays previous month, current month and next month calendar
10. $cal year – it displays the given year calendar
Eg: $cal 2005 --it takes year from 1 t0 9999
11. $Cal month year – it displays the given month calendar only
12. #Init --to change system run levels
i. #Init 0 -to shutdown the system
ii. #Init 1 – to bring the system to single user mode
iii. #Init 2 –to bring the system to multi user mode with no resource shared.
iv. #Init 3 –to bring the system multi user mode with resource shared
v. #Init 6 – halt and reboot the system to the default run level.
13. $banner “Bayon” – it prints a message in large letters
Creating files
There are two commands to create files 1. Touch and cat
1. Touch filename - it creates zero byte file size
Eg: $ touch sample
The size of sample file is zero bytes. Touch does not allow you store anything in a file. It is used for to create several empty files quickly.
Eg: $ touch file1 file2 file3 file4 file5
2.cat command
Syntax
i. $Cat >filename
E.g.: $cat >sample
----------------
----------------
----------------
Ctrl+d (to close a file)
ii. $Cat >> sample --to append data to the file
----------------
----------------
----------------
Ctrl+d
iii. $Cat file1 file2 file3 >file4
This would create file4 which contains contents of file1 followed by file2 and
Followed by that of file3. i.e., it concatenates file1, file2 and file3 contents and
Redirects to file4. If file4 already contains something it would be over written.
3. $ Cat <filename or $cat filename --to open a file
E.g: $cat sample --it displays sample file contents
E.g: $cat file1 file2 file3
-It displays file1 contents followed by file2 then followed by file3.
Removing files
4. Rm command -to removes the given file
Syntax: $rm filename
$Rm sample -it removes sample file
$Rm –I filename -it asks confirmation before deleting the file.
$Rm – sample
Remove sample? y –it removes
N – it won’t remove
$Rm file1 file2 file3 -it removes three files
$Rm * -it removes all files in current directory
Creating directory
5. Mkdir command -to make directory
Syntax: $mkdir directory name
e.g: mkdir techno
Creating multiple directories
$Mkdir dir1 dir2 dir3 …darn
Change directory
Syntax: $cd directory name
$Cd tecnosoft
$Pwd
/usr/tecno/tecnosoft
$cd .. –to change into parent directory
$cd\ -to change to root directory
Remove directory
1. $rmdir directory name -to delete a directory but directory should be empty
2. $rm –r directory name – it removes all files and sub directories, sub directory files
Including directory.

Directories:
File and directory paths in UNIX use the forward slash "/" to separate directory Names in a path.
Examples: / "root" directory
/usr directory usr (sub-directory of / "root" directory)
/usr/STRIM100 STRIM100 is a subdirectory of /usr
Moving around the file system:
pwd Show the "present working directory", or current directory.
cd Change current directory to your HOME directory.
cd - go to previous directory(like undo).
cd /usr/STRIM100 Change current directory to /usr/STRIM100.
cd INIT Change current directory to INIT which is a sub-directory of the current
directory.
cd .. Change current directory to the parent directory of the current directory.
cd $STRMWORK Change current directory to the directory defined by the
environment variable 'STRMWORK'.
cd ~bob Change the current directory to the user bob's home directory (if you
have permission).
ls list a directory
ls -l list a directory in long ( detailed ) format
Example:
$ ls -l
drwxr-xr-x 4 cliff user 1024 Jun 18 09:40 WAITRON_EARNINGS
-rw-r--r-- 1 cliff user 767392 Jun 6 14:28 scanlib.tar.gz
| | | | | owner group size date time name
| | | | number of links to file or directory contents
| | | permissions for world
| | permissions for members of group
| permissions for owner of file: r = read, w = write, x = execute -=no permission
type of file: - = normal file, d=directory, l = symbolic link, and others...
drwxr-xr-x first 1 letter is indicate directiry or file, d is directory,- is file.
Next 9 letters are indicate owner(3), group(3), user(3) rights resp.
ls -a List the current directory including hidden files. Hidden files start with "."
ls -ld * List all the file and directory names in the current directory using long format.
Without the "d" option, ls would list the contents of any sub-directory of the
current. With the "d" option, ls just lists them like regular files.
ls t* list all directories or files which start with ‘t’
Changing file permissions and attributes:
chmod 755 file Changes the permissions of file to be rwx for the owner, and rx for
the group and the world.(7 = rwx = 111 binary. 5 = r-x = 101 binary)
chgrp user file Makes file belong to the group user.
chown cliff file Makes cliff the owner of file.
chown -R cliff dir Makes cliff the owner of dir and everything in its directory tree.
You must be the owner of the file/directory or be root before you can do any of these things.
Moving, renaming, and copying files:
cp file1 file2 copy a file(if file2 not exists it will create a new file)
mv file1 newname move or rename a file(rename)
mv file1 /AAA/bbb move file1 into sub-directory AAA in your home directory.
rm file1 [file2 ...] remove or delete a file
rmdir dir1 [dir2...] remove an empty directory
rm -r dir1 [dir2...] recursively remove a directory and its contents BE CAREFUL!
mkdir dir1 [dir2...] create directories
mkdir -p dirpath create the directory dirpath, including all implied directories in the
path.
cmp [options] file1 file2 compare two files and list where differences occur
(text or binary files)
diff [options] file1 file2 compare the two files and display the differences
(text files only)
chsh (passwd -e/-susername login_shell change the user's login shell
(often only by the superuser)
date [options] report the current date and time
emacs [options] file full-screen editor
file [options] file classify the file type
ftp [options] host transfer file(s) using file transfer protocol
lpr [options] file or lp [options] file print to defined printer
passwd [options] set or change your password
wc file count number of lines/words/characters in file
who list users currently logged in
Viewing and editing files:
cat filename Dump a file to the screen in ascii.
more filename Progressively dump a file to the screen: ENTER = one line down
SPACEBAR = page down q=quit
less filename Like more, but you can use Page-Up too. Not on all systems.
vi filename Edit a file using the vi editor. All UNIX systems will have vi in some form.
emacs filename Edit a file using the emacs editor. Not all systems will have emacs.
head filename Show the first few lines of a file.
head -n filename Show the first n lines of a file.
tail filename Show the last few lines of a file.
tail -n filename Show the last n lines of a file.
Shells
The behavior of the command line interface will differ slightly depending on the shell program that is being used. Depending on the shell used, some extra behaviors can be quite nifty. You can find out what shell you are using by the command:
echo $SHELL
Of course you can create a file with a list of shell commands and execute it like a program to perform a task. This is called a shell script. This is in fact the primary purpose of most shells, not the interactive command line behavior.
Environment variables:
You can teach your shell to remember things for later using environment variables.
For example under the bash shell:
Export CASROOT=/usr/local/CAS3.0 Defines the variable CASROOT with the value
Export LD_LIBRARY_PATH=$CASROOT/Linux/lib Defines the variable
LD_LIBRARY_PATH with the value
Of CASROOT with /Linux/lib
ppended, or /usr/local/CAS3.0/Linux/lib
By prefixing $ to the variable name, you can evaluate it in any command:
cd $CASROOT Changes your present working directory to the value of CASROOT
echo $CASROOT Prints out the value of CASROOT, or /usr/local/CAS3.0
printenv CASROOT Does the same thing in bash and some other shells.
Interactive History:
A feature of bash and tcsh (and sometimes others) you can use the up-arrow keys to access your previous commands, edit them, and re-execute them.
Filename Completion:
A feature of bash and tcsh (and possibly others) you can use the TAB key to complete a partially typed filename. For example if you have a file called constantine-monks-and-willy-wonka.txt in your directory and want to edit it you can type 'vi const', hit the TAB key, and the shell will fill in the rest of the name for you (provided the completion is unique).
Bash is the way cool shell:
Bash will even complete the name of commands and environment variables. And if there are multiple completions, if you hit TAB twice bash will show you all the completions. Bash is the default user shell for most Linux systems.
Redirection:
grep string filename > newfile Redirects the output of the above grep
command to a file 'newfile'.
grep string filename >> existfile Appends the output of the grep command
to the end of 'existfile'.
The redirection directives, > and >> can be used on the output of most commands to direct their output to a file.
Pipes:
The pipe symbol "|" is used to direct the output of one command to the input of another.
For example:
ls -l | more This commands takes the output of the long format directory list command
"ls -l" and pipes it through the more command (also known as a filter).
In this case a very long list of files can be viewed a page at a time.
du -sc * | sort -n | tail
The command "du -sc" lists the sizes of all files and directories in the current working directory. That is piped through "sort -n" which orders the output from smallest to largest size. Finally, that output is piped through "tail" which displays only the last few (which just happen to be the largest) results.
Command Substitution:
You can use the output of one command as an input to another command in another way called command substitution. Command substitution is invoked when by enclosing the substituted command in backwards single quotes.
For example:
cat `find . -name aaa.txt`
which will cat ( dump to the screen ) all the files named aaa.txt that exist in the current
directory or in any subdirectory tree.
Searching for strings in files: The grep command
grep string filename prints all the lines in a file that contain the string
Searching for files : The find command
find search_path -name filename
find . -name aaa.txt Finds all the files named aaa.txt in the current directory or
any subdirectory tree.
find / -name vimrc Find all the files named 'vimrc' anywhere on the system.
find /usr/local/games -name "*xpilot*"
Find all files whose names contain the string 'xpilot' which exist within the '/usr/local/games' directory tree.
Reading and writing tapes, backups, and archives: The tar command
The tar command stands for "tape archive". It is the "standard" way to read and write archives (collections of files and whole directory trees).
Often you will find archives of stuff with names like stuff.tar, or stuff.tar.gz. This is stuff in a tar archive, and stuff in a tar archive which has been compressed using the gzip compression program respectivly.
Chances are that if someone gives you a tape written on a UNIX system, it will be in tar format,and you will use tar (and your tape drive) to read it.
Likewise, if you want to write a tape to give to someone else, you should probably use tar as well.
Tar examples:
tar xv Extracts (x) files from the default tape drive while listing (v = verbose)
the file names to the screen.
tar tv Lists the files from the default tape device without extracting them.
tar cv file1 file2 Write files 'file1' and 'file2' to the default tape device.
tar cvf archive.tar file1 [file2...] Create a tar archive as a file "archive.tar" containing
file1, file2...etc.
tar xvf archive.tar extract from the archive file
tar cvfz archive.tar.gz dname Create a gzip compressed tar archive containing
everything in the directory 'dname'. This does not
work with all versions of tar.
tar xvfz archive.tar.gz Extract a gzip compressed tar archive. Does not work with all
versions of tar.
tar cvfI archive.tar.bz2 dname Create a bz2 compressed tar archive. Does not work
with all versions of tar.
File compression: compressgzip, and bzip2
The standard UNIX compression commands are compress and uncompress. Compressed files have a suffix .Z added to their name.
For example:
compress part.igs Creates a compressed file part.igs.Z
uncompress part.igs Uncompresseis part.igs from the compressed file part.igs.Z.
Note the .Z is not required.
Another common compression utility is gzip (and gunzip). These are the GNU compress and uncompress utilities. gzip usually gives better compression than standard ompress, but may not be installed on all systems. The suffix for gzipped files is .gz
gzip part.igs Creates a compressed file part.igs.gz
gunzip part.igs Extracts the original file from part.igs.gz
The bzip2 utility has (in general) even better compression than gzip, but at the cost of longer times to compress and uncompress the files. It is not as common a utility as gzip, but is becoming more generally available.
bzip2 part.igs Create a compressed Iges file part.igs.bz2
bunzip2 part.igs.bz2 Uncompress the compressed iges file.
Looking for help: The man and apropos commands
Most of the commands have a manual page which give sometimes useful, often more or less detailed, sometimes cryptic and unfathomable discriptions of their usage. Some say they are called man pages because they are only for real men.
Example:
man ls Shows the manual page for the ls command You can search through the man
pages using apropos
Example:
apropos build Shows a list of all the man pages whose discriptions contain the word
"build"
Do a man apropos for detailed help on apropos.
Basics of the vi editor
Opening a file : vi filename
Creating text :
Edit modes: These keys enter editing modes and type in the text of your document.
i Insert before current cursor position
I Insert at beginning of current line
a Insert (append) after current cursor position
A Append to end of line
r Replace 1 character
R Replace mode
<ESC> Terminate insertion or overwrite mode
Deletion of text:
x Delete single character
dd Delete current line and put in buffer
ndd Delete n lines (n is a number) and put them in buffer
J Attaches the next line to the end of the current line (deletes carriage return).
Oops:
u Undo last command
cut and paste
yy Yank(copy) current line into buffer
nyy Yank n lines into buffer
p Put the contents of the buffer after the current line(paste)
P Put the contents of the buffer before the current line
Cursor positioning:
^d Page down
^u Page up
:n Position cursor at line n
:$ Position cursor at end of file
^g Display current line number
h,j,k,l Left,Down,Up, and Right respectivly. Your arrow keys should also work if your keyboard mappings are anywhere near sane.
String substitution:
: n1, n2: s/string1/string2/ [g] Substitute string2 for string1 on lines n1 to n2. If g is
included (meaning global), all instances of string1 on
each line are substituted. If g is not included, only the
first instance per matching line is substituted.
^ matches start of line matches any single character
$ matches end of line These and other "special characters" (like the forward slash)
can be "escaped" with \ i.e to match the string
"/usr/STRIM100/SOFT" say "\/usr\/STRIM100\/SOFT"
Examples:
:1,$:s/dog/cat/g Substitute 'cat' for 'dog', every instance for the entire file - lines 1
to $ (end of file)
:23,25:/frog/bird/ Substitute 'bird' for 'frog' on lines 23 through 25. Only the first
instance on each line is substituted.
Saving and quitting and other "ex" commands
These commands are all prefixed by pressing colon (:) and then entered in the lower left corner of the window. They are called "ex" commands because they are commands of the ex text editor - the precursor line editor to the screen editor vi. You cannot enter an "ex" command when you are in an edit mode (typing text onto the screen)
Press <ESC> to exit from an editing mode.
:w Write the current file.
:w new.file Write the file to the name 'new.file'.
:w! existing.file Overwrite an existing file with the file currently being edited.
:wq Write the file and quit.
:q Quit.
:q! Quit with no changes.
:e filename Open the file 'filename' for editing.
:set number Turns on line numbering
:set nonumber Turns off line numbering
Remove (unlink) the FILE(s). rm
-d, --directory
unlink FILE, even if it is a non-empty directory (super-user
only)
-f, --force
ignore nonexistent files, never prompt
-i, --interactive
prompt before any removal
-r, -R, --recursive
remove the contents of directories recursively
-v, --verbose
explain what is being done
--help display this help and exit
--version
output version information and exit
To remove a file whose name starts with a â-â, for example â-fooâ, use
one of these commands:
rm.td/rm -- -foo
rm.td/rm ./-foo
Note that if you use rm to remove a file, it is usually possible to
recover the contents of that file. If you want more assurance that the
contents are truly unrecoverable, consider using shred.
SEARCHING
/pattern * Search forward for (N-th) matching line.
?pattern * Search backward for (N-th) matching line.
n * Repeat previous search (for N-th occurrence).
N * Repeat previous search in reverse direction.
ESC-n * Repeat previous search, spanning files.
ESC-N * Repeat previous search, reverse dir. & spanning files.
ESC-u Undo (toggle) search highlighting.
---------------------------------------------------
Search patterns may be modified by one or more of:
^N or ! Search for NON-matching lines.
^E or * Search multiple files (pass thru END OF FILE).
^F or @ Start search at FIRST file (for /) or last file (for ?).
^K Highlight matches, but don't move (KEEP position).
^R Don't use REGULAR EXPRESSIONS.
---------------------------------------------------------------------------
JUMPING
g < ESC-< * Go to first line in file (or line N).
G > ESC-> * Go to last line in file (or line N).
p % * Go to beginning of file (or N percent into file).
t * Go to the (N-th) next tag.
T * Go to the (N-th) previous tag.
{ ( [ * Find close bracket } ) ].
} ) ] * Find open bracket { ( [.
ESC-^F <c1> <c2> * Find close bracket <c2>.
ESC-^B <c1> <c2> * Find open bracket <c1>
CHANGING FILES
:e [file] Examine a new file.
^X^V Same as :e.
:n * Examine the (N-th) next file from the command line.
:p * Examine the (N-th) previous file from the command line.
:x * Examine the first (or N-th) file from the command line.
:d Delete the current file from the command line list.
= ^G :f Print current file name.
@ Rotate the code recognition method of the current file.
Ksb
-? ........ --help
Display help (from command line).
-a ........ --search-skip-screen
Forward search skips current screen.
-b [N] .... --buffers=[N]
Number of buffers.
-B ........ --auto-buffers
Don't automatically allocate buffers for pipes.
-c -C .... --clear-screen --CLEAR-SCREEN
Repaint by scrolling/clearing.
-d ........ --dumb
Dumb terminal.
-D [xn.n] . --color=xn.n
Set screen colors. (MS-DOS only)
-e -E .... --quit-at-eof --QUIT-AT-EOF
Quit at end of file.
-f ........ --force
Force open non-regular files.
-F ........ --quit-if-one-screen
Quit if entire file fits on first screen.
-g ........ --hilite-search
Highlight only last match for searches.
-G ........ --HILITE-SEARCH
Don't highlight any matches for searches.
-h [N] .... --max-back-scroll=[N]
Backward scroll limit.
-i ........ --ignore-case
Ignore case in searches that do not contain uppercase.
-I ........ --IGNORE-CASE
Ignore case in all searches.
-j [N] .... --jump-target=[N]
Screen position of target lines.
-J ........ --status-column
Display a status column at left edge of screen.
-k [file] . --lesskey-file=[file]
Use a lesskey file.
-K [charset]
Specify character set.
-m -M .... --long-prompt --LONG-PROMPT
Set prompt style.
-n -N .... --line-numbers --LINE-NUMBERS
LINE EDITING
These keys can be used to edit text being entered
on the "command line" at the bottom of the screen.
RightArrow ESC-l Move cursor right one character.
LeftArrow ESC-h Move cursor left one character.
CNTL-RightArrow ESC-RightArrow ESC-w Move cursor right one word.
CNTL-LeftArrow ESC-LeftArrow ESC-b Move cursor left one word.
HOME ESC-0 Move cursor to start of line.
END ESC-$ Move cursor to end of line.
BACKSPACE Delete char to left of cursor.
DELETE ESC-x Delete char under cursor.
CNTL-BACKSPACE ESC-BACKSPACE Delete word to left of cursor.
CNTL-DELETE ESC-DELETE ESC-X Delete word under cursor.
MKDIR
`mkdir' creates directories with the specified names. Synopsis:
mkdir [OPTION]... NAME...
If a NAME is an existing file but not a directory, `mkdir' prints a
warning message on stderr and will exit with a status of 1 after
processing any remaining NAMEs. The same is done when a NAME is an
existing directory and the -p option is not given. If a NAME is an
existing directory and the -p option is given, `mkdir' will ignore it.
That is, `mkdir' will not print a warning, raise an error, or change
the mode of the directory (even if the -m option is given), and will
move on to processing any remaining NAMEs.
CAT
`cat': Concatenate and write files
==================================
`cat' copies each FILE (`-' means standard input), or standard input
if none are given, to standard output. Synopsis:
cat [OPTION] [FILE]...
The program accepts the following options. Also see *Note Common
options::.
`-A'
`--show-all'
Equivalent to `-vET'.
`-B'
`--binary'
On MS-DOS and MS-Windows only, read and write the files in binary
mode. By default, `cat' on MS-DOS/MS-Windows uses binary mode
only when standard output is redirected to a file or a pipe; this
option overrides that. Binary file I/O is used so that the files
retain their format (Unix text as opposed to DOS text and binary),
because `cat' is frequently used as a file-copying program. Some
options (see below) cause `cat' to read and write files in text
mode because in those cases the original file contents aren't
important (e.g., when lines are numbered by `cat', or when line
endings should be marked). This is so these options work as
DOS/Windows users would expect; for example, DOS-style text files
have their lines end with the CR-LF pair of characters, which
won't be processed as an empty line by `-b' unless the file is
read in text mode.
`-b'
`--number-nonblank'
Number all nonblank output lines, starting with 1. On MS-DOS and
MS-Windows, this option causes `cat' to read and write files in
text mode.
`-e'
The program accepts the following options. Also see *Note Common
options::.
`-m MODE'
`--mode=MODE'
Set the mode of created directories to MODE, which is symbolic as
in `chmod' and uses `a=rwx' (read, write and execute allowed for
everyone) minus the bits set in the umask for the point of the
departure. *Note File permissions::.
`-p'
`--parents'
Make any missing parent directories for each argument. The mode
for parent directories is set to the umask modified by `u+wx'.
Ignore arguments corresponding to existing directories.
`-v'
`--verbose'
Print a message for each created directory. This is most useful
with `--parents'
LS
The `ls' program lists information about files (of any type,
including directories). Options and file arguments can be intermixed
arbitrarily, as usual.
For non-option command-line arguments that are directories, by
default `ls' lists the contents of directories, not recursively, and
omitting files with names beginning with `.'. For other non-option
arguments, by default `ls' lists just the file name. If no non-option
argument is specified, `ls' operates on the current directory, acting
as if it had been invoked with a single argument of `.'.
By default, the output is sorted alphabetically, according to the
locale settings in effect. (1) If standard output is a terminal, the
output is in columns (sorted vertically) and control characters are
output as question marks; otherwise, the output is listed one per line
and control characters are output as-is.
Because `ls' is such a fundamental program, it has accumulated many
options over the years. They are described in the subsections below;
within each section, options are listed alphabetically (ignoring case).
The division of options into the subsections is not absolute, since some
options affect more than one aspect of `ls''s operation.
Also see *Note Common options::.
* Menu:
* Which files are listed::
* What information is listed::
* Sorting the output::
* More details about version sort::
* General output formatting::
* Formatting file timestamps::
* Formatting the file names:
TOUCH
`touch' changes the access and/or modification times of the
specified files. Synopsis:
touch [OPTION]... FILE...
On older systems, `touch' supports an obsolete syntax, as follows.
If the first FILE would be a valid argument to the `-t' option and no
timestamp is given with any of the `-d', `-r', or `-t' options and the
`--' argument is not given, that argument is interpreted as the time
for the other files instead of as a file name. POSIX 1003.1-2001
(*note Standards conformance::) does not allow this; use `-t' instead.
Any FILE that does not exist is created empty.
If changing both the access and modification times to the current
time, `touch' can change the timestamps for files that the user running
it does not own but has write permission for. Otherwise, the user must
own the files.
Although `touch' provides options for changing two of the times -
the times of last access and modification - of a file, there is actually
a third one as well: the inode change time. This is often referred to
as a file's `ctime'. The inode change time represents the time when
the file's meta-information last changed. One common example of this
is when the permissions of a file change. Changing the permissions
doesn't access the file, so the atime doesn't change, nor does it
modify the file, so the mtime doesn't change. Yet, something about the
file itself has changed, and this must be noted somewhere. This is the
job of the ctime field. This is necessary, so that, for example, a
backup program can make a fresh copy of the file, including the new
permissions value. Another operation that modifies a file's ctime
without affecting the others is renaming. In any case, it is not
possible, in normal operations, for a user to change the ctime field to
a user-specified value.
TR
`tr': Translate, squeeze, and/or delete characters
==================================================
Synopsis:
tr [OPTION]... SET1 [SET2]
`tr' copies standard input to standard output, performing one of the
following operations:
* translate, and optionally squeeze repeated characters in the
result,
* squeeze repeated characters,
* delete characters,
* delete characters, then squeeze repeated characters from the
result.
The SET1 and (if given) SET2 arguments define ordered sets of
characters, referred to below as SET1 and SET2. These sets are the
characters of the input that `tr' operates on. The `--complement'
(`-c') option replaces SET1 with its complement (all of the characters
that are not in SET1).
* Menu:
* Character sets:: Specifying sets of characters.
* Translating:: Changing one characters to another.
* Squeezing:: Squeezing repeats and deleting.
* Warnings in tr:: Warning messages.
WC
`wc': Print byte, word, and line counts
=======================================
`wc' counts the number of bytes, characters, whitespace-separated
words, and newlines in each given FILE, or standard input if none are
given or for a FILE of `-'. Synopsis:
wc [OPTION]... [FILE]...
`wc' prints one line of counts for each file, and if the file was
given as an argument, it prints the file name following the counts. If
more than one FILE is given, `wc' prints a final line containing the
cumulative counts, with the file name `total'. The counts are printed
in this order: newlines, words, characters, bytes. By default, each
count is output right-justified in a 7-byte field with one space
between fields so that the numbers and file names line up nicely in
columns. However, POSIX requires that there be exactly one space
separating columns. You can make `wc' use the POSIX-mandated output
format by setting the `POSIXLY_CORRECT' environment variable.
By default, `wc' prints three counts: the newline, words, and byte
counts. Options can specify that only certain counts be printed.
Options do not undo others previously given, so
wc --bytes --words
prints both the byte counts and the word counts.
With the `--max-line-length' option, `wc' prints the length of the
longest line per file, and if there is more than one file it prints the
maximum (not the sum) of those lengths.
The program accepts the following options. Also see *Note Common
options::.
`-c'
`--bytes'
Print only the byte counts.
PASTE
`paste' writes to standard output lines consisting of sequentially
corresponding lines of each given file, separated by a TAB character.
Standard input is used for a file name of `-' or if no input files are
given.
For example:
$ cat num2
1
2
$ cat let3
a
b
c
$ paste num2 let3
1 a
2 b
c
Synopsis:
paste [OPTION]... [FILE]...
The program accepts the following options. Also see *Note Common
options::.
`-s'
`--serial'
Paste the lines of one file at a time rather than one line from
each file. Using the above example data:
$ paste -s num2 let3
1 2
a b c
CMP
NAME
cmp - compare two files
SYNOPSIS
cmp [-l | -s] file1 file2 [skip1 [skip2]]
DESCRIPTION
The cmp utility compares two files of any type and writes the results to
the standard output. By default, cmp is silent if the files are the
same; if they differ, the byte and line number at which the first differ-
ence occurred is reported.
Bytes and lines are numbered beginning with one.
The following options are available:
-l Print the byte number (decimal) and the differing byte values
(octal) for each difference.
-s Print nothing for differing files; return exit status only.
The optional arguments skip1 and skip2 are the byte offsets from the
beginning of file1 and file2, respectively, where the comparison will
begin. The offset is decimal by default, but may be expressed as an hex-
adecimal or octal value by preceding it with a leading ââ0xââ or ââ0ââ.
The cmp utility exits with one of the following values:
0 The files are identical.
1 The files are different; this includes the case where one file is
identical to the first part of the other. In the latter case, if
the -s option has not been specified, cmp writes to standard output
that EOF was reached in the shorter file (before any differences
were found).
UNIQ
`uniq' writes the unique lines in the given `input', or standard
input if nothing is given or for an INPUT name of `-'. Synopsis:
uniq [OPTION]... [INPUT [OUTPUT]]
By default, `uniq' prints the unique lines in a sorted file, i.e.,
discards all but one of identical successive lines. Optionally, it can
instead show only lines that appear exactly once, or lines that appear
more than once.
The input need not be sorted, but duplicate input lines are detected
only if they are adjacent. If you want to discard non-adjacent
duplicate lines, perhaps you want to use `sort -u'.
Comparisons use the character collating sequence specified by the
`LC_COLLATE' locale category.
If no OUTPUT file is specified, `uniq' writes to standard output.
The program accepts the following options. Also see *Note Common
options::.
`-f N'
`--skip-fields=N'
Skip N fields on each line before checking for uniqueness. Fields
are sequences of non-space non-tab characters that are separated
from each other by at least one space or tab.
On older systems, `uniq' supports an obsolete option `-N'. POSIX
1003.1-2001 (*note Standards conformance::) does not allow this;
use `-f N' instead.
`-s N'
`--skip-chars=N'
Skip N characters before checking for uniqueness. If you use both
the field and character skipping options, fields are skipped over
first.
`sort': Sort text files
=======================
`sort' sorts, merges, or compares all the lines from the given
files, or standard input if none are given or for a FILE of `-'. By
default, `sort' writes the results to standard output. Synopsis:
sort [OPTION]... [FILE]...
`sort' has three modes of operation: sort (the default), merge, and
check for sortedness. The following options change the operation mode:
`-c'
`--check'
Check whether the given files are already sorted: if they are not
all sorted, print an error message and exit with a status of 1.
Otherwise, exit successfully.
`-m'
`--merge'
Merge the given files by sorting them as a group. Each input file
must always be individually sorted. It always works to sort
instead of merge; merging is provided because it is faster, in the
case where it works.
A pair of lines is compared as follows: if any key fields have been
specified, `sort' compares each pair of fields, in the order specified
on the command line, according to the associated ordering options,
until a difference is found or no fields are left. Unless otherwise
specified, all comparisons use the character collating sequence
specified by the `LC_COLLATE' locale. (1)
If any of the global options `bdfgiMnr' are given but no key fields
are specified, `sort' compares the entire lines according to the global
options.
Finally, as a last resort when all keys compare equal (or if no
ordering options were specified at all), `sort' compares the entire
lines. The last resort comparison honors the `--reverse' (`-r') global
`cut': Print selected parts of lines
====================================
`cut' writes to standard output selected parts of each line of each
input file, or standard input if no files are given or for a file name
of `-'. Synopsis:
cut [OPTION]... [FILE]...
In the table which follows, the BYTE-LIST, CHARACTER-LIST, and
FIELD-LIST are one or more numbers or ranges (two numbers separated by
a dash) separated by commas. Bytes, characters, and fields are
numbered starting at 1. Incomplete ranges may be given: `-M' means
`1-M'; `N-' means `N' through end of line or last field. The list
elements can be repeated, can overlap, and can be specified in any
order; but the selected input is written in the same order that it is
read, and is written exactly once.
The program accepts the following options. Also see *Note Common
options::.
`-b BYTE-LIST'
`--bytes=BYTE-LIST'
Print only the bytes in positions listed in BYTE-LIST. Tabs and
backspaces are treated like any other character; they take up 1
byte.
`-c CHARACTER-LIST'
`--characters=CHARACTER-LIST'
Print only characters in positions listed in CHARACTER-LIST. The
same as `-b' for now, but internationalization will change that.
Tabs and backspaces are treated like any other character; they
take up 1 character.
`-f FIELD-LIST'
`--fields=FIELD-LIST'
Print only the fields listed in FIELD-LIST. Fields are separated
by a TAB character by default. Also print any line that contains
no delimiter character, unless the `--only-delimited' (`-s')
option is specified
`echo': Print a line of text
============================
`echo' writes each given STRING to standard output, with a space
between each and a newline after the last one. Synopsis:
echo [OPTION]... [STRING]...
The program accepts the following options. Also see *Note Common
options::.
`-n'
Do not output the trailing newline.
`-e'
Enable interpretation of the following backslash-escaped
characters in each STRING:
`\a'
alert (bell)
`\b'
backspace
`\c'
suppress trailing newline
`\f'
form feed
`\n'
new line
`\r'
carriage return
`\t'
horizontal tab

No comments:

Post a Comment