GNU

basename – strip directory and suffix from filenames

A UNIX Command
$basename
basename: missing operand
Try `basename --help' for more information.
$basename /usr/bin/
bin
$basename /usr/
usr
$
$basename /usr/bin/less
less
$basename /usr/include/ma
malloc.h  math.h
$basename /usr/include/math.h
math.h
$basename /usr/include/math.h .
math.h
$basename /usr/include/math.h .h
math
$basename /usr/lib/libgccpp.so.1
libgccpp.so.1
$basename /usr/lib/libgccpp.so.1 .1
libgccpp.so
$

UNIX Explanation
`basename' removes any leading directory components from NAME.
Synopsis:

     basename NAME [SUFFIX]

If SUFFIX  is specified  and is identical  to the  end of
NAME, it is  removed from NAME as well.   Note that since
trailing  slashes are removed  prior to  suffix matching,
SUFFIX   will  do   nothing  if   it   contains  slashes.
`basename' prints the result on standard output.

Together, `basename' and `dirname' are designed such that
if `ls  "$name"' succeeds, then the  command sequence `cd
"$(dirname  "$name")";  ls  "$(basename "$name")"'  will,
too.   This  works   for  everything  except  file  names
containing a trailing newline.

POSIX allows the implementation  to define the results if
NAME  is  empty  or   `//'.   In  the  former  case,  GNU
`basename' returns the empty string.  In the latter case,
the result is `//' on platforms where // is distinct from
/, and `/' on platforms where there is no difference.


id – print real and effective user and group IDs

A UNIX Command
$id
uid=1000(jeffrin) gid=1000(jeffrin) groups=1000(jeffrin),29(audio),1001(wireshark)
$id -n
id: cannot print only names or real IDs in default format
$id -a
uid=1000(jeffrin) gid=1000(jeffrin) groups=1000(jeffrin),29(audio),1001(wireshark)
$id -g
1000
$id -G
1000 29 1001
$id -Gn
jeffrin audio wireshark
$id -r
id: cannot print only names or real IDs in default format
$id -rG
1000 29 1001
$id -u
1000
$id -un
jeffrin
$

UNIX Explanation

GNU/Linux Based Explanation
Print  user  and  group  information  for  the  specified
USERNAME, or (when USERNAME omitted) for the current user

SunOS Based Explanation
If no user operand is provided, the id utility writes the
user and  group IDs and the corresponding  user and group
names of the invoking process to standard output.  If the
effective and real IDs do not match, both are written. If
multiple groups  are supported by  the underlying system,
/usr/xpg4/bin/id  also  writes  the  supplementary  group
affiliations of the invoking process.


If a  user operand  is provided and  the process  has the
appropriate  privileges, the  user and  group IDs  of the
selected user  are written.  In this  case, effective IDs
are assumed to be identical  to real IDs. If the selected
user has more than  one allowable group membership listed
in  the group database,  /usr/xpg4/bin/id writes  them in
the same manner as  the supplementary groups described in
the preceding paragraph.

FreeBSD Based Explanation
The  id utility  displays the  user and  group  names and
numeric  IDs, of  the  calling process,  to the  standard
output.   If the  real and  effective IDs  are different,
both are  displayed, otherwise only  the real ID  is dis-
played.

If a user (login name  or user ID) is specified, the user
and group IDs of that  user are displayed.  In this case,
the real and effective IDs are assumed to be the same.

truncate – shrink or extend the size of a file to the specified size

A UNIX Command

$cat example.text
hello
$ls -l example.text
-rw-r--r-- 1 jeffrin jeffrin 6 Jun 21 02:32 example.text
$truncate -s 10 example.text
$ls -l example.text
-rw-r--r-- 1 jeffrin jeffrin 10 Jun 21 02:35 example.text
$hexdump example.text
0000000 6568 6c6c 0a6f 0000 0000
000000a
$cat example.text
hello
$truncate -s 9 example.text
$ls -l example.text
-rw-r--r-- 1 jeffrin jeffrin 9 Jun 21 02:36 example.text
$hexdump example.text
0000000 6568 6c6c 0a6f 0000 0000
0000009
$

UNIX Explanation

`truncate' shrinks  or extends the  size of each  FILE to
the specified size.If a FILE is larger than the specified
size, the extra  data is lost.  If a  FILE is shorter, it
is extended and the extended part (or hole) reads as zero
bytes.

coreutils: ls –quoting-style=c and | (pipe) symbol


http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=432945

output of ls --quoting-style=c is incorrect when filename contains |
(pipe) symbol.

Steps:
  mkdir /tmp/bla
  touch "/tmp/bla/filename with | pipe"
  ls --quoting-style=c /tmp/bla

returns:

 "filename with \| pipe"

thanks,
-Mathieu

Ref:
http://groups.google.com/group/comp.lang.c/browse_thread/thread/0db8070def6a4453


Unevictable: 4 kB 0.1

Unevictable:           4 kB
The Unevictable LRU infrastructure addresses the following classes of
unevictable pages:

+ page owned by ram disks or ramfs
+ page mapped into SHM_LOCKed shared memory regions
+ page mapped into VM_LOCKED [mlock()ed] vmas
Least  Recently Used  (LRU): discards  the least  recently  used items
first. This  algorithm requires keeping  track of what was  used when,
which  is expensive if  one wants  to make  sure the  algorithm always
discards the least recently used item. General implementations of this
technique require  to keep  "age bits" for  cache-lines and  track the
"Least  Recently   Used"  cache-line   based  on  age-bits.   In  such
implementation, every time a cache-line  is used, the age of all other
cache-lines changes.  LRU is actually  a family of  caching algorithms
with members including:  2Q by Theodore Johnson and  Dennis Shasha and
LRU/K by Pat O'Neil, Betty O'Neil and Gerhard Weikum.

Hugetlb pages are also  unevictable. Hugepages are already implemented
in a way  that these pages don't  reside on the LRU and  hence are not
iterated over during  the vmscan.  So there is no  need to move around
these pages  across different  LRU's. We just  account these  pages as
unevictable for correct statistics.


The Unevictable LRU  adds an additional LRU list  to track unevictable
pages and to hide these pages from vmscan.  This mechanism is based on
a patch  by Larry  Woodman of Red  Hat to address  several scalability
problems with page reclaim in  Linux.  The problems have been observed
at  customer sites  on large  memory x86_64  systems.  For  example, a
non-numal x86_64 platform with 128GB  of main memory will have over 32
million 4k  pages in a  single zone.  When  a large fraction  of these
pages are not evictable for  any reason [see below], vmscan will spend
a lot of time scanning the LRU lists looking for the small fraction of
pages that  are evictable.  This can  result in a  situation where all
cpus are  spending 100% of their time  in vmscan for hours  or days on
end, with the system completely unresponsive.

comm – compare two sorted files line by line



$comm sorta.txt sortb.txt
d
g
comm: file 1 is not in sorted order
e
s

x
comm: file 2 is not in sorted order
g
s
n

$cat sorta.txt
d
g
e
s

$cat sortb.txt
x
g
s
n

$

$cat sorta.txt
a
b
c
d
$cat sortb.txt
a
f
g
h
$comm sorta.txt sortb.txt
a
b
c
d
f
g
h
$
comm - compare two sorted files line by line

With no options, produce three-column output.
Column one contains lines unique to FILE1, column
two contains lines unique to FILE2, and column three
contains lines common to both files.

Reference/Source :
Debian manual for command "comm".

cut –help



$cat workethics.txt
Work ethics in QA Fashion

$cut -c1-5 workethics.txt
Work

$cut -c1 workethics.txt
W

$cut -f1 workethics.txt
Work ethics in QA Fashion

$cut -b1 workethics.txt
W

$cut -b2 workethics.txt
o

$cut -b0 workethics.txt
cut: fields and positions are numbered from 1
Try `cut --help' for more information.

cut - remove sections from each line of files
-c, --characters=LIST
-b, --bytes=LIST select only these bytes
select only these characters
$

Reference/Source :
Debian Manual for "cut" command.

Note: http://lowfatlinux.com/linux-columns-cut.html