Your Ad Here

Sabtu, 31 Juli 2010

Unix Tip: REMOVING CORES CONDITIONALLY

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3460 - July 31, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


REMOVING CORES CONDITIONALLY

To find and remove core files
conditionally:

PROMPT> find ~ -name core -exec file {} \; -exec rm -i {} \;

The File will show which
executable the core file is
for and the -i option to rm
will allow you to choose
weather to delete it or not.

################# EXAMPLE ###############################
PROMPT> find ~ -name core -exec file {} \; -exec rm -i {} \;
/my/home/core: ELF 32-bit LSB core file of 'netscape-commun'
(signal 3), Intel 8
rm: remove `/my/home/core'? y


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Jumat, 30 Juli 2010

Unix Tip: INSERTING LINES WITHIN SCRIPTS

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3459 - July 30, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


INSERTING LINES WITHIN SCRIPTS


If you want to insert a line
at the top (or anywhere for
that matter) of a file within
a shell script, use the ed editor.

EXAMPLE:

string="hello"
ed << EOF
e any_file
1i
${string}


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Kamis, 29 Juli 2010

Unix Tip: Rename files script

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3458 - July 29, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Rename files script

If you want to rename files
in a directory then you can
use the following perl
script....

#!/usr/bin/perl
# rename: renames files according to the expr given on the command line.
# The expr will usually be a 's' or 'y' command, but can be any valid
# perl command if it makes sense. Takes a list of files to work on or
# defaults to '*' in the current directory.
# e.g.
# rename 's/\.flip$/.flop/' # rename *.flip to *.flop
# rename s/flip/flop/ # rename *flip* to *flop*
# rename 's/^s\.(.*)/$1.X/' # switch sccs filenames around
# rename 's/$/.orig/' */*.[ch] # add .orig to your source files in */
# rename 'y/A-Z/a-z/' # lowercase all filenames in .
# rename 'y/A-Z/a-z/ if -B' # same, but just binaries!
# rename chop *~ # restore all ~ backup files

use Getopt::Std;
my ($subst, $name);

if (!&getopts("nfq") || $#ARGV == -1) {
die "Usage: rename [-fnq] <perl expression> [file file...]
-f : Force the new filename even if it exists already
-n : Just print what would happen, but don't do the command
-q : Don't print the files as they are renamed
e.g. : rename 's/\.c/.c.old/' *
rename -q 'y/A-Z/a-z/' *\n";
}

$subst = shift; # Get perl command to work on
@ARGV = <*> if $#ARGV < 0; # Default to complete directory

foreach $name (@ARGV) {
$_ = $name;
eval "$subst;";
die $@ if $@;
next if -e $_ && !$opt_f; # Skip if the file exists if asked to.
mext if $_ eq $name;
if ($opt_n) {
print "mv $name $_\n";
next;
}
print "mv $name $_\n" if !$opt_q;
rename($name,$_) or warn "Can't rename $name to $_, $!\n";
}

Put the script called rename in /usr/local/bin. Make sure
/usr/local/bin is in your $PATH for convenience.


This tip generously supported by: dave.ruddle@siemens.co.uk


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Rabu, 28 Juli 2010

Unix Tip: BOURNE SHELL PSEUDO HASH TABLES

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3457 - July 28, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


BOURNE SHELL PSEUDO HASH TABLES

The best way to explain this
is with an example:

You may want to write a simple
script that launches an xterm
window with different color
options. Pseudo hash tables in
bourne shell.

$ xwindow MidnightBlue

An easy way to this is by first
listing the supported colors in
the script (pseudo hash table):

DarkSlateGrey="#2f4f4f"
DimGrey="#696969"
MidnightBlue="#191970"
NavyBlue="#000080"

Next, simply grab the hex color
code by using the following
command:

BGColor=`eval echo $"$(echo $1)"`

"$(echo $1)" evaluates to "MidnightBlue" and
`eval echo $MidnightBlue evaluates to "#191970".

Simply launch the xterm window
using $BGColor as the background
color:

xterm -bg="$BGColor" &

This method for extracting pseudo hash
values may be used for NIS map files,
file date stamps, GUI colors, etc.


This tip generously supported by: Jasper.Silvis@PHL.Boeing.com


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Selasa, 27 Juli 2010

Unix Tip: BE A GURU - RTFM

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3456 - July 27, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


BE A GURU - RTFM

The best way, is to learn
to be the best Unix Guru is
take the time to RTFM. Do
not always depend on someone
else to be there with the
knowledge.

DON'T BE LAZY!

By the Way, for those that
don't know by now.

RTFM = READ THE F^CKING MANUAL


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Senin, 26 Juli 2010

Unix Tip: ONE STEP AT A TIME WITH !!

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3455 - July 26, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


ONE STEP AT A TIME WITH !!

For example using C shell I want
to edit a handful of files that
contain the string "ProcessInput"
in my current directory.

Step 1:
Find the files which uses "ProcessInput"

% grep "ProcessInput" *.c
a.c:ProcessInput ( int a )
b.c:Description : ProcessInput is used to process the input
given by the user
b.c:Call ProcessInput to perform ...
c.c:val = ProcessInput(2) ;
c.c:val = ProcessInput(3) ;

Step 2:
Extract the filenames on the left.
$!! | awk -F: '{print $1}'
a.c
b.c
b.c
c.c
c.c

step 3:
Remove the duplicates
!! | sort -u

Step 4:
Now edit it !
vi `!!`

which runs vi `grep "ProcessInput" *.c | awk -F: '{print $1}'
| sort -u`


This tip generously supported by: desikann@future.futsoft.com


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Minggu, 25 Juli 2010

Unix Tip: PRINTING WITH NO SPACE

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3454 - July 25, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


PRINTING WITH NO SPACE

Sometimes there isn't enough space
in the spooling directory to print
a large file. This isn't the case
so much anymore since disk drives
are so large now.

If the file fills up the spooling
directory use and you are using
BSD "lpr" then you can pass it
the -s option.

This will create a symlink to the
file instead of coping it.

"lp" creates a symlink by default.
You can use the -c options to
force it to copy the file instead,
if needed.

Some flavors differ, check yours.


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Sabtu, 24 Juli 2010

Unix Tip: To grab all hidden files

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3453 - July 24, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


To grab all hidden files

A safe way of grabbing all "hidden"
files is to use '.??*' rather than
'.*' since this will only match 3
or more characters. Admittedly,
this will miss any hidden files
that are only a single character
after the ., but it will always
miss '.' & '..', which is probably
more important...

We can use .[a-zA-Z0-9]* to grab
all hidden files other
than . and .. we will not get
hidden files which dont have any
alphanumeric character following
the first '.' - can someone tell
how to go about this


This tip generously supported by: muraliaj@synopsys.com


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Jumat, 23 Juli 2010

Unix Tip: SAVE A COPY

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3452 - July 23, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


SAVE A COPY

Ever edited a file, then wished
you'd saved a copy first?

This script will save it for you.
It even handles multiple files,
and multiple edits of the same file.

############### Cut here ##########
#!/bin/ksh
# My vi : Save a backup of the file(s) to edit
for file in $* ; do
if [[ -a $file ]] ; then
basefile=`basename $file`
cp $file ~/bak/${basefile}.`date +%C%y%m%d%H%M%S`
fi
done
/usr/bin/vi $*
############### Cut here ##########

You'll need to create a directory
called 'bak' in your $HOME directory,
and it would be a good idea to set up
a cron job to clear out old copies
periodically.


This tip generously supported by:
gordon.morrison@vf.vodafone.co.uk


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Kamis, 22 Juli 2010

Unix Tip: KEEPING PEOPLE OUT

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3451 - July 22, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


KEEPING PEOPLE OUT

If you want to keep people
of your server, but want them
to access their pop mail on
the same box set up the following
line in the password file:

babba:rtnRkIgCy4l4T:830:10:Babba Booie:/home/babba:/bin/nologin


Then create a script called
/bin/nologin that contains:

#! /bin/sh
echo "Sorry, but your account is only allowed POP access to this host."
exit 1

when a person attempts to log into
their defined shell it will run
the /bin/noling script, display
the message, and exit them from
the system

Have Fun

--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Rabu, 21 Juli 2010

Unix Tip: STRING STRIPPING

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3450 - July 21, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


STRING STRIPPING

Remove all ^M and other control
characters from file ABC

strings ABC > ABC-good


This tip generously supported by:
brillj@constellation.navy.mil


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Selasa, 20 Juli 2010

Unix Tip: TEXT FILE CASE REVERSAL

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3449 - July 20, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


TEXT FILE CASE REVERSAL


Ever want to reverse the entire case
of a text file:

o reverse the case of a text file:
tr 'a-zA-Z' 'A-Za-z' < inputfile


This tip generously supported by: vikram.kalsi@seepz.tcs.co.in


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Senin, 19 Juli 2010

Unix Tip: VI MAN PAGES

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3448 - July 19, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


VI MAN PAGES

Try saving a man page to
a file for viewing with vi.

You will see a whole bunch
of control characters.

How can you save a man page
in a form readable by vi?

$ man ls | col -b > readable_file.txt


This tip generously supported by: kmehta@legato.com


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Minggu, 18 Juli 2010

Unix Tip: VI LINE NUMBERS

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3447 - July 18, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


VI LINE NUMBERS


Ever want line numbers
while editing a file:

:set number

We can see the line numbers...

--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Sabtu, 17 Juli 2010

Unix Tip: GETTING RID OF ^M

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3446 - July 17, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


GETTING RID OF ^M

=======================================
MYSPACE IS HIRING LINUX ADMINS
Support thousands of Linux servers
http://tinyurl.com/2g82crv
=======================================

How to get rid of ^M
in text files .

tr -d '^M' <inputfile >outputfile

But how to get this
'^M' in the command
line:

Keep CTRL pressed
and then press v and m

This tip generously supported by: sojan@psidata.com


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Jumat, 16 Juli 2010

Unix Tip: REMOVE JUST THE FILES

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3445 - July 16, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


REMOVE JUST THE FILES

=======================================
MYSPACE NEEDS YOU TO APPLY TODAY!
Join their team supporting one of the
largest Linux sites you may ever seen
http://tinyurl.com/2g82crv
=======================================

To removal only the files
(not subdirectories) in
the current directory, use
the following command:

rm `ls -l | grep -v '^d' | awk '{ print $9 }'`


This tip generously supported by: rrs@assc.com.ve


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Kamis, 15 Juli 2010

Unix Tip: SOLARIS CHANGING SEASONS

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3444 - July 15, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


SOLARIS CHANGING SEASONS

========================================
LINUX ADMINS LOVE WORKING AT MYSPACE
Manage cutting edge cluster technologies
http://tinyurl.com/2g82crv
========================================


During a session, sometimes
we have a need to change the
system time for our session
only. We have used it to
simulate time based testing.

export TZ=ESThhEDT

The EST set your time to Eastern
Standard Time and EDT is Eastern
Daylight Time.

hh is the number of hours you
wish to change.

Example: Currently the system
date is Tue Jun 19 13:38:03 EDT 2001

and you wish to set it to
yesterday at the same time.
You would substitute a positive
29 for hh.

export TZ=EST29EDT

Now the shell time is:
Mon Jun 18 13:38:50 EDT 2001

WHY 29 and not 24? The main
UNIX clock is set from GMT not
EST therefore you have to add
5 hours to your backward
calculations to get the same
exact time since EST is
GMT - 5 hours.

Use negitive numbers to set
the clock into the future.

Also if you need to set the
minutes and seconds it is
hh:mm:ss. These are all the
number of hours, minutes and
seconds from GMT that you wish
to set.

This is for Solaris 2.6, your
mileage may vary.

--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Rabu, 14 Juli 2010

Unix Tip: TAR ONLY THE FILES

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3443 - July 14, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


TAR ONLY THE FILES

=======================================
MYSPACE WANTS TO SEE YOUR RESUME
If you LOVE being a Linux Admin
http://tinyurl.com/2g82crv
=======================================

To tar only files (not
subdirectories) in the
current directory use
this command:

$ tar cvf files.tar ./`ls -l | grep -v '^d' | awk '{ print $9 }'`

This tip generously supported by: rrs@assc.com.ve


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Selasa, 13 Juli 2010

Unix Tip: SHELL OUTPUT INTO VI

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3442 - July 13, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


SHELL OUTPUT INTO VI


=======================================
JOIN THE EXCLUSIVE MYSPACE UNIX TEAM
Apply Today!
http://tinyurl.com/2g82crv
=======================================

In VI editor you can get
the output of any shell
command command inserted
into the file you are
editing by using:

:r!<command>

For example:

:r!who -r

inserts the ouput of the
command "who -r" to the
file currently being
edited.

This can be effectively used
to copy the contents of a
file to the file currently
being edited

ie,

:r!cat /etc/passwd

inserts all the contents of
the the /etc/passwd to the
file currently being edited.

This tip supported by: Prem Kumar S <sprem@wipro.co.in>


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Senin, 12 Juli 2010

Unix Tip: APPENDING TEXT AT BOTH ENDS

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3079 - July 12, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


APPENDING TEXT AT BOTH ENDS

If you need to append some
text to both the ends of a
string in vi, use the
following command in vi:

:/^\(.*\)/s//starttextcomeshere \1 endtextcomeshere/

If "iamworthless" is the text
at the position of the cursor
in the vi editor, the output
of the command:

:/^\(.*\)/s//DONTFEEL \1 ANYTIME/


DONTFEEL iamworthless ANYTIME

As you guessed, "DONTFEEL " and
" ANYTIME" are the strings you
would like to crush
"iamworthless" with. The "\1" is
the variable that stores the
entire pattern searched by
the "/\(.*\)/"

This tip generously supported by: hg_krishnan@yahoo.com

--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Minggu, 11 Juli 2010

Unix Tip: CONVERTING UNIX MAN PAGES

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3078 - July 11, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


CONVERTING UNIX MAN PAGES

(Another approach)

To convert Unix Man pages
to text format, you can make
use of one feature of 'man'
itself.

(Check out man man)

Set environment variable PAGER
to 'cat'. Then run

% man command_name > command_name.txt

eg. in csh, to see man ls in
a text file

% setenv PAGER cat
% man ls > ls.txt

NOTE: Do not forget to unsetenv
PAGER, else you will have to
pipe every man command to
'more' or (my favourite) 'less'.


This tip generously supported by: amar_san@yahoo.com


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Sabtu, 10 Juli 2010

Unix Tip: REMOVING FILES WITH BAD FILE NAMES

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3077 - July 10, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


REMOVING FILES WITH BAD FILE NAMES

If a file has a special
character, Unix will try to
interpret the character.
Renaming these type of files
cannot be done with a simple
"mv".....it will have to be
done using the file's inode.

For example:
# ls -i "GSO (website)"
(the "-i" flag will display the file's inode)
41734 GSO(website)

...the inode for the "bad" file is "41734"

1. once the inode is identified, use the find command to
rename the file:

find . -inum 41734 -exec mv \{\} NewName \;

2. do an "ls" to verify


This tip generously supported by: arimaldo@earthlink.net


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Jumat, 09 Juli 2010

Unix Tip: CSH PROMPT SETTING

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3076 - July 9, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


CSH PROMPT SETTING

In (t)csh, here is a better way to
set your prompt to always let you
know where on the system you are.
In your .cshrc file, add
or set the following line:

set prompt = "%m%/% "

This way, whenever you press return,
or a job finishes, the prompt will
always tell you where you are,
without having to change directories
first. Of extra usefulness, the '%m%'
token expands to the machine name.
If you work on a multimachine system,
knowing which machine you're on is
usually of more immediate importance
than where on the machine you are.

--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Kamis, 08 Juli 2010

Unix Tip: CONVERT TEXT2HTML

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3075 - July 8, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


CONVERT TEXT2HTML

Ever felt the need to convert a
text file to html?

Create a file named txt2html
with the following contents

# Always start the output with
#an html header

BEGIN {print "<html>"
print "<head>"

# use the name of the inputfile
# as title

print "<title>" FILENAME "</title>"
print "</head>"

# The text is formatted
# already, so use <pre>

print "<body><pre>"}

# lines consisting of a number
# of dashes (more than 1) are
# replaced by a <hr>

/^---*$/ {print "<hr align=\"left\" width=" length "0 size=1>"; next}

# lines consisting of a number of equalsigns are replaced
# by a thick <hr>

/^===*$/ {print "<hr align=\"left\" width=" length "0 size=3>"; next}

# less than and greater than
# sign must me replaced by tags.

{gsub("<","\&lt;")
gsub(">","\&gt;")

# Replace form feeds by a
# couple of empty lines

gsub("^L","<br>\&nbsp;<br>\&nbsp;<br>\&nbsp;<br>")
print}

# At the end of the output,
# we must add some closing tags.

END {print "</pre></body>"}

Make this executable
(chmod a+x txt2html) and you're
ready to start converting your test files.

txt2html something.txt > something.html


This tip generously supported by: ugu@couprie.org


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Rabu, 07 Juli 2010

Unix Tip: EFFICIENT COMMANDS

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3074 - July 7, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


EFFICIENT COMMANDS

I cringe anytime I see someone code
inefficiently. Here are three of the
most common mistakes, followed by a
better way to do the same thing.

Bad: cat somefile | grep something
Better: grep something somefile
Why: You're running one program (grep) instead of two (cat and grep).

Bad: ps -ef | grep something | grep -v grep
Better: ps -ef | grep [s]omething
Why: You're running two commands (grep) instead of three (ps
and two greps).

Bad: cat /dev/null > somefile
Better: > somefile
Why: You're running a command (cat) with I/O redirection,
instead of just redirection.

Although the bad way will have the
same result, the good way is far
faster. This may seem trivial, but
the benefits will really show when
dealing with large files or loops.

Regards.

This tip generously supported by: sec@nbnet.nb.ca


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Selasa, 06 Juli 2010

Unix Tip: TOO MANY FILES AROUND

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3073 - July 6, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


TOO MANY FILES AROUND

In case there are too many
files in a particular
directory. When the
following is executed:

$grep "ABC" *

And it fails saying with

ksh: /usr/bin/find: 0403-027 The parameter list is too long.

what would you do?

Well you can do the following:

$ls |xargs grep "ABC"

-----
Puneet Agarwal
This tip generously supported by: puneeta@delhi.tcs.co.in

--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Senin, 05 Juli 2010

Unix Tip: EXTRACT RELATIVE FROM ABSOLUTE

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3072 - July 5, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


EXTRACT RELATIVE FROM ABSOLUTE

Ever had a tar archive which
was tarred up with an absolute
path, but you need to untar
it to a relative location?

There is an easy way to do
this using the "pax" command.
Note: Not available on all
flavors.

Firstly, copy the archive to
the relative location in
which you wish to untar it.

Then, execute the following
command:

pax -r -s ',^/,,' -f file.tar

The contents of file.tar will now
be in the $CWD.

--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Minggu, 04 Juli 2010

Unix Tip: BELIEVE THE VENDOR?

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3071 - July 4, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


BELIEVE THE VENDOR?

Don't always feel that you should
believe the vendor.

Patches, vendor recommendations,
and out-sourced hardware support
engineers are some of the leading
causes of breaking a system. There
are times when you know your systems
better then they do.

If something doesn't feel right or
doesn't feel right , don't let them
do it. Ask a lot of questions and let
them know what your experience is.

Cover yourself first, run full
backups, ask them if the have ever
done the task before. Ask them to
confirm the procedure with a back
level support person.

Many times vendors will out-source
the hardware support to third party
companies. When this happens, you
may never get the same person twice,
nor know what experience he has on
your system.

If one of the first things a support
person does is ask where a phone is,
it is almost a guarantee that he will
lack the knowledge he should have and
will need to rely on someone else for
answer. While we all have much work
to do, DON'T LEAVE this type of person
alone with your systems.

Trust no one, it is you job and
reputation on the line.


-Kirk Waingrow

The tip is supported by: kirk@ugu.com


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Sabtu, 03 Juli 2010

Unix Tip: REMOVING CORES CONDITIONALLY

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3070 - July 3, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


REMOVING CORES CONDITIONALLY

To find and remove core files
conditionally:

PROMPT> find ~ -name core -exec file {} \; -exec rm -i {} \;

The File will show which
executable the core file is
for and the -i option to rm
will allow you to choose
weather to delete it or not.

################# EXAMPLE ###############################
PROMPT> find ~ -name core -exec file {} \; -exec rm -i {} \;
/my/home/core: ELF 32-bit LSB core file of 'netscape-commun'
(signal 3), Intel 8
rm: remove `/my/home/core'? y


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Jumat, 02 Juli 2010

Unix Tip: INSERTING LINES WITHIN SCRIPTS

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3069 - July 2, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


INSERTING LINES WITHIN SCRIPTS


If you want to insert a line
at the top (or anywhere for
that matter) of a file within
a shell script, use the ed editor.

EXAMPLE:

string="hello"
ed << EOF
e any_file
1i
${string}


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Kamis, 01 Juli 2010

Unix Tip: Rename files script

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3068 - July 1, 2010

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Rename files script

If you want to rename files
in a directory then you can
use the following perl
script....

#!/usr/bin/perl
# rename: renames files according to the expr given on the command line.
# The expr will usually be a 's' or 'y' command, but can be any valid
# perl command if it makes sense. Takes a list of files to work on or
# defaults to '*' in the current directory.
# e.g.
# rename 's/\.flip$/.flop/' # rename *.flip to *.flop
# rename s/flip/flop/ # rename *flip* to *flop*
# rename 's/^s\.(.*)/$1.X/' # switch sccs filenames around
# rename 's/$/.orig/' */*.[ch] # add .orig to your source files in */
# rename 'y/A-Z/a-z/' # lowercase all filenames in .
# rename 'y/A-Z/a-z/ if -B' # same, but just binaries!
# rename chop *~ # restore all ~ backup files

use Getopt::Std;
my ($subst, $name);

if (!&getopts("nfq") || $#ARGV == -1) {
die "Usage: rename [-fnq] <perl expression> [file file...]
-f : Force the new filename even if it exists already
-n : Just print what would happen, but don't do the command
-q : Don't print the files as they are renamed
e.g. : rename 's/\.c/.c.old/' *
rename -q 'y/A-Z/a-z/' *\n";
}

$subst = shift; # Get perl command to work on
@ARGV = <*> if $#ARGV < 0; # Default to complete directory

foreach $name (@ARGV) {
$_ = $name;
eval "$subst;";
die $@ if $@;
next if -e $_ && !$opt_f; # Skip if the file exists if asked to.
mext if $_ eq $name;
if ($opt_n) {
print "mv $name $_\n";
next;
}
print "mv $name $_\n" if !$opt_q;
rename($name,$_) or warn "Can't rename $name to $_, $!\n";
}

Put the script called rename in /usr/local/bin. Make sure
/usr/local/bin is in your $PATH for convenience.


This tip generously supported by: dave.ruddle@siemens.co.uk


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Your Ad Here
Free Automatic Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink