Your Ad Here

Minggu, 20 Desember 2009

Unix Tip: SPACES TO UNDERSORE 1 LINER

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3240 - December 20, 2009

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

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


SPACES TO UNDERSORE 1 LINER

Do you hate users who put spaces in file names, preventing you from doing any sort of scripting?

Well then this is the little one-liner for you to pop in a shell script then...

for i in $1 ; do mv "$i" `echo $i | sed 's/ /_/g'` ; done

the echo $i | sed 's/ /_/g' is surrounded by back-tics not regular quotes.

--------------------------------------------------------------------------
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, 19 Desember 2009

Unix Tip: NEW TIP BETTER THAN OLD TIP!

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3239 - December 19, 2009

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

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


NEW TIP BETTER THAN OLD TIP!

Sorry about the Y2K tip, we have been testing a new Tip mailer. Hated it!
Here is the real tip that was suppose to go out today:

------------------------------

WALK THE CUBES

Some times at work there are dry periods when the users don't call. Walk the halls even if there is nothing to do. Being seen by users makes them feel that you are always around for them.

Some users are hesitant to call at times, and some feel you are never around to help. When you walk the area ask different users each time if everything is alright. A simple way to stay proactive.

Also, if you charge your time back to a department, make sure that you walk past managers offices. They will feel that you are there to work on the employees problems and they're being well taken care of. Even if everythig is okay, and they ask what the problems are, let them know you are there because you care.

Alittle TLC goes along ways.


--------------------------------------------------------------------------
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, 18 Desember 2009

Unix Tip: REGULAR EXPRESSION FOR FLOATING POINT NUMBER

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3238 - December 18, 2009

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

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


REGULAR EXPRESSION FOR FLOATING POINT NUMBER

This the Regular expression for floating point numbers and this can be used with grep or egrep for searching floating point numbers in any text file.

(\+|-)?([0-9]+\.?[0-9]*|\.[0-9]+)([eE](\+|-)?[0-9]+)?


This tip generously supported by: udayk@india.hp.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
==========================================================================

Kamis, 17 Desember 2009

Unix Tip: CHANGING PERMS RECURSIVELY

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3237 - December 17, 2009

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

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


CHANGING PERMS RECURSIVELY

*** NOTE: Odly enough, the previous mailing of this tip did not go through do to a permissions problem. Sorry.

To change permissions recursively for all files in a directory

find dirname -exec chmod xxx {} \; -print

where dirname is the directory you want to change permissions.


This tip generously supported by: avsrao_india@hotmail.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, 13 Desember 2009

Unix Tip: REMOVING BLANK LINES

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3233 - December 13, 2009

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

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


REMOVING BLANK LINES

To remove blank lines from a file using sed, use the following:

sed -e '/^$/d' filetoread >filetowrite

The ^ matches the beginning of a line and the $ matches the end. The two of them together matches a line that begins and ends with nothing in between (blank line).
The d just says delete the lines for which we have a match. Since the standard operation of sed is to print every line, all lines exept blank lines will be sent to filetowrite.


This tip generously supported by: code@ionet.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
==========================================================================

Rabu, 09 Desember 2009

Unix Tip: WHAT TIME IS IT REMOTELY?

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3229 - December 9, 2009

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

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


WHAT TIME IS IT REMOTELY?

To get time on a remote UNIX machine within the same domain, you can use the command:

% telnet 13

Trying ...
Connected to
Escape character is '^]'.
Fri Aug 27 19:20:27 1999
Connection closed by foreign host.

You can create a handy alias for the following command to get the remote time:

telnet 13 | grep :


This tip generously supported by: bhavin@informix.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, 06 Desember 2009

Unix Tip: PM THE SYSTEMS

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3226 - December 6, 2009

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

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


PM THE SYSTEMS

It is always a good idea to provide preventative maintenance on systems and workstations:

* Blow out or vacuum dust
* Reset memory
* clean up loose cables
* Label equipment
* Verify configuration
* Document any changes

Holidays are good times when systems are under utilized. If users are around, schedule the downtime. It is just one more way for the user community to see that you care.

hey, maybe you'll even get a Christmas gift from them too.

Merry Christmas.....


--------------------------------------------------------------------------
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, 26 November 2009

Unix Tip: MOVING FILES AROUND

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3216 - November 26, 2009

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

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


MOVING FILES AROUND

Here is another way to move files around.

Sometimes you find yourself wanting to move a bunch of files into a new directory that is to be created in the current working directory.

Rather than using a temporary directory, or grep and variable substitution; use a subshell:

$ ( \ls; echo dir; mkdir dir ) | xargs mv

The trick is in using a subshell to run a number of commands _before_ the output is piped to xargs. This idiom is also useful for plenty of other applications.


--------------------------------------------------------------------------
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, 22 November 2009

Unix Tip: GETTING IPs FROM IFCONFIG

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3212 - November 22, 2009

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

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


GETTING IPs FROM IFCONFIG

You can use ifconfig to lookup IP addresses bound to your box. If you do not want to search the output from ifconfig, use the following command to get just the IP listing.

ifconfig | awk '/inet/{print $2}' | awk -F: '{print $2}'

--------------------------------------------------------------------------
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, 21 November 2009

Unix Tip: PING THE HOST TABLE

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3211 - November 21, 2009

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

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


PING THE HOST TABLE

There's no need to grep and pipe the output into awk (you can "grep" with awk.)

awk '/^[0-9]/{print $1}' /etc/hosts |xargs -l ping -c 1 $1


This tip generously supported by: bmaclean@silverplatter.com

And another:

awk '/^[^#]/ {system("ping -c 1 "$1)}' < /etc/hosts


This tip generously supported by: maddox@xmission.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, 20 November 2009

Unix Tip: USES FOR AWK

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3210 - November 20, 2009

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

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


USES FOR AWK

If you have a server with alot of filesystems on it (oracle/SAP environments) then this little awk command can come in useful. It can obviously be used in many other situations also. In this example, the file structure is /oracle/PRD/xxxx.

awk '/PRD/{ print "umount " $3 }' /etc/vfstab | /sbin/sh

If you run it without piping it to 'sh', then it will show you what the command will do. You can replace the 'umount' with whatever command you like. It's a quick and easy though.


--------------------------------------------------------------------------
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, 19 November 2009

Unix Tip: PERL FIND AND REPLACE

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3209 - November 19, 2009

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

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


PERL FIND AND REPLACE

In UNIX environment, the following combination of perl and find will serch for a particular file and replace the occurence of a particular string with another string in that file. This will also work for multiple files and directories. The find command finds the file and the perl script replaces old string with the new one.


At the command prompt give this command:

# perl -pi -e 's/<old string>/<new string>' `find . -name "<file name>"`

NB: Perl should be in the path and the general regular expression rules apply while using special characters for eg / or .


This tip generously supported by: pandpr@dh.cit.alcatel.fr


--------------------------------------------------------------------------
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, 18 November 2009

Unix Tip: BE ALARMED

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3208 - November 18, 2009

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

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


BE ALARMED

Name the following script alarm. Make it executable and them invoke it as:

% alarm 10 "Time for tea"

After 10 seconds machine will echo Time for Tea and beep five times.....

---------------

#! /usr/bin/ksh
# alarm program
# displays a message at
if [ $# -ne 2 ]
then
echo "USAGE : $0 seconds message"
exit 1
fi

time=$1
mesg=$2
signal_alarm()
{
sleep $time
banner $mesg
for i in 1 2 3 4 5 6 7 8 9
do
if [ $i -eq 2 -o $i -eq 4 -o $i -eq 6 -o $i -eq 8 ]
then
sleep 1
else
tput bel
fi
done
}

case $1 in

[0-9][0-9][0-9] | [0-9] | [0-9][0-9] )signal_alarm &;;
*)echo Seconds range is from 0 to 199;;

esac

--------------------------------------------------------------------------
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, 17 November 2009

Unix Tip: NUMBERING A FILE

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3207 - November 17, 2009

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

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


NUMBERING A FILE

Ever want line numbers appended to a file. Here is a short script.

awk '{no=no+1; printf"%d : %s", no, $0}' filename > filename.out

Another shorter but not necessary elegant method is:

grep -n . filename > filename.out

filename is the original file filenmae.out is the file with line numbers appended at the beginning of each line


This tip generously supported by: pradeep@unixguru.zzn.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
==========================================================================

Senin, 16 November 2009

Unix Tip: BACKING UP FILES

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3206 - November 16, 2009

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

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


BACKING UP FILES

Ever needed to backup all of your configuration files in one fail swoop?

Using an editor create a file:

vi configlist

Enter the full path of the files needed to backup.

/etc/passwd
/etc/inetd.conf
/etc/hosts/allow
/etc/hosts.deny
and so on until you have a full list of files.
Save the file and quit

:wq!

Compress the files using tar:

tar cvfzT /tmp/backup.tar.gz configlist
tar: Removing leading `/` from absolute path names in the archive
etc/passwd
etc/inetd.conf

WARNING! This file contains some files that could only be read by a limited number of users. Store it carefully so only the Administrator can access it.

Check "man tar" on your flavor, the "z" and "T" options are not available on all flavors of unix.

This tip generously supported by: darren.mallett@tradermedia.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
==========================================================================

Sabtu, 14 November 2009

Unix Tip: MANIPULATE MULTIPLE FILES

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3204 - November 14, 2009

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

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


MANIPULATE MULTIPLE FILES

If you have a directory with large number of files and you want to rename or copy or process it, here is a simple way to do it;

# for temp in *
> do
> echo cp $temp $temp.org >> t.txt
> done

You can change the copy command to what ever that you need to do. This will create a file tmp.txt with all the files listed in the current working directory and insert a line into the file tmp.txt as;

cp filename filename.org


This tip generously supported by: tyl@computer.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
==========================================================================

Kamis, 12 November 2009

Unix Tip: COMMENT OUT MULTIPLE LINES

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3202 - November 12, 2009

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

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


COMMENT OUT MULTIPLE LINES

Ever wanted to comment out multiple lines of code while writing shell scripts in vi, but didn't want to pound your keyboard for half an hour doing it?

(I#Escape j.j.j.j. = carpal tunnel)

Here's the nerdy way to do it:

:.,+N-1 s/^/#/g

Where N-1 is the number of lines minus one that you want to comment out, and s/^/#/g is the regular expression (the pattern between the first two slashes is what you want to replace, in this case the beginning of the line, and the pattern between the last two slashes is what you want to replace it with).

For example, if you're a bad coder like me and want to comment out 500 lines of code, you would do:

:.,+499 s/^/#/g


This tip generously supported by: maddox@xmission.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
==========================================================================

Rabu, 11 November 2009

Unix Tip: HOW MUCH SOLARIS MEMORY?

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3201 - November 11, 2009

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

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


HOW MUCH SOLARIS MEMORY?

To determine the amount of main memory on Solaris:
1) /usr/platform/sun4u/sbin/prtdiag
2) wsinfo
3) '/usr/sbin/prtconf | grep -i memory'


This tip generously supported by: M.Nithyanandham@blr.spcnl.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
==========================================================================

Jumat, 06 November 2009

Unix Tip: VERIFY AFTER VACATIONS

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3196 - November 6, 2009

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

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


VERIFY AFTER VACATIONS

Be sure to check all vital systems and processes once returning froma vacation.

Don't ignore your log files or backup reports. You may have alot of email from automated jobs. READ ALL OF THEM!


--------------------------------------------------------------------------
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, 05 November 2009

Unix Tip: FIND AND EDIT IN ONE

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3195 - November 5, 2009

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

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


FIND AND EDIT IN ONE

Have You Ever found a need to find a file for a particular pattern and then edit the same ??

Here is an easiest way....

At the UNIX prompt, Just type:

vi `find . -name "*" -exec grep -l "pattern" {} \; -print`

Where "pattern" is the string to be searched.


--------------------------------------------------------------------------
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, 04 November 2009

Unix Tip: CARROTS ARE GOOD FOR YOU

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3194 - November 4, 2009

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

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


CARROTS ARE GOOD FOR YOU

Most often when we try to execute a command at the shell we do some mistakes like missing out a char or misspelling it. Here is a easy way of correcting the mistake without having to type the entire command again!.

In the below command "name" has been misspelled as "naem"

$ find . -naem "*.txt" -print
find: invalid predicate `-naem'

The above command would be valid if we replace "em" (in naem) to "me"( to have name ). Use carrots to make this change

$ ^em^me^
find . -name "*.txt" -print

This technique works well with bash and csh.

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
==========================================================================

Selasa, 03 November 2009

Unix Tip: WHERE ARE THOSE PARENTHESES?

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3193 - November 3, 2009

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

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


WHERE ARE THOSE PARENTHESES?

Do you ever lose your way in multiple levels of parentheses or braces? If you program in Perl or C, you know what I mean. Let the vi "%" command help you. Move the cursor to a parenthesis or brace and type %. vi will move the cursor to the corresponding character. Hit % again and vi will return to the original parenthesis or brace.

For extra power, issue "/{" to find the first open brace. Hit "%" twice to find the corresponding brace and return. Hit "n" to find the next open brace. This allows you to zip through the file checking your program structure.

It makes you feel sorry for Windows-based editors!


--------------------------------------------------------------------------
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, 02 November 2009

Unix Tip: GREP TEXT NOT BINARY

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3192 - November 2, 2009

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

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


GREP TEXT NOT BINARY

In some directories such as /etc you have a mix of file types. You may want to grep out a string from one of the files but don't want to worry about the binaries, data, etc. To accomplish this, searching only text files do this:

grep <string> `file * | egrep 'script|text' | awk -F: '{print $1}'`


This tip generously supported by: Richard.place-eds@eds.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, 31 Oktober 2009

Unix Tip: FINDING A STRING

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3190 - October 31, 2009

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

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


FINDING A STRING

How to find a string somewhere on the system. Many times we are called to search for a string, but we have no idea where it may be lurking. Judicious use of the find and grep commands will make you a hero with your co-workers.

# find . -type f -exec grep "string or options" /dev/null {} \;

Normally using only:
# find . -type f -exec grep "string/options" {} \;

Produces the target string, but you will have no clue as to where it is located, making this almost as frustrating as using windoze! Remember when grep'ing against multiple files the filename will be listed before the match.

$ grep there *
foo:I found the target here
bar:You are there

In our find command we use /dev/null as a file to search against, since we know the search will always fail if the string is found in "{}" there filename is printed. To borrow from a famous quote: "Pretty tricky sis!"

This tip generously supported by: james_b_horwath@glic.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, 30 Oktober 2009

Unix Tip: RANDOM LINES FROM A FILE

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3189 - October 30, 2009

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

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


RANDOM LINES FROM A FILE

A easy way to retrieve random lines from a text file:

perl -e '$count = 10; @line = <>; for (1..$count) { print $line[int rand @line] }'

example:
% cat /etc/passwd | perl -e '$count = 10; @line = <>; for (1..$count) { print $line[int rand @line] }'

This tip generously supported by: abend@110.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
==========================================================================

Kamis, 29 Oktober 2009

Unix Tip: EXTRACT THAT LAST FIELD

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3188 - October 29, 2009

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

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


EXTRACT THAT LAST FIELD

You can use 'cut' to extract the last field of a line if you know how many fields there are, eg:

field=`cut -d: -f8 file`

But if you don't know the maximum number of fields or the number of fields per line are not consistent, awk can come to the rescue. awk has the inbuilt variable NF for the number of fields. By using this variable we can use it to extract the last field by using:

field=`awk -F: '{print $NF}'`

or you can use calculations to retrieve any field relative to the last field. For example to retrieve the second last field, use:

field=`awk -F: '{print $(NF-1)}'`


This tip generously supported by: peters@ginini.com.au


--------------------------------------------------------------------------
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 Oktober 2009

Unix Tip: FORGET THE CRONTAB MAN

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3186 - October 27, 2009

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

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


FORGET THE CRONTAB MAN

For some reason many admins forget the field order of the crontab file and alway reference the man pages over-and-over. Make your life easy. Just put the field definitions in your crontab file and comment (#) the lines out so the crontab file ignores it.

#minute (0-59),
#| hour (0-23),
#| | day of the month (1-31),
#| | | month of the year (1-12),
#| | | | day of the week (0-6 with 0=Sunday).
#| | | | | commands
0 2 * * 0,4 /etc/cron.d/logchecker


--------------------------------------------------------------------------
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 Oktober 2009

Unix Tip: POWER OF BACKQUOTES

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3185 - October 26, 2009

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

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


POWER OF BACKQUOTES

Backquotes are the most powerful things in Unix. More than one Unix commands can be run simultaneously on the prompt. In csh,

% find . -name "*.txt" -print

gives the path & names of the files with extension ".txt" in current directory and its subdirectories. If you want to open these files in vi together then

% vi `find . -name "*.txt" -print`

Similarly,

% find . -name "*.txt" -print
<listing of all txt files. in current directory/sub-dirs>
% vi `!!`

this will open all those files in vi listed by find command.


This tip generously supported by: dhruvm@duettech.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 Oktober 2009

Unix Tip: PING THE HOST TABLE

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3184 - October 25, 2009

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

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


PING THE HOST TABLE

Here is a quick way to ping all the hosts in your host table. NOTE: Just make sure that there are no blank lines in it, and verify the ping command on your system exist after one ping. Your mileage may differ slightly.

$ grep -v "#" /etc/hosts | awk '{print $1}' | while read host
> do
> ping -c 1 $host
> done

Or script it:

#!/bin/sh
grep -v "#" /etc/hosts | awk '{print $1}' | while read host
do
ping -c 1 $host
done

--------------------------------------------------------------------------
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 Oktober 2009

Unix Tip: A SHAMELESS PLUG

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3183 - October 24, 2009

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

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


A SHAMELESS PLUG

The Best Tip I can give you right now is to pick up a copy of UNIX HINTS AND HACKS By the Creator of UGU.

It is available at Barnes & Nobles, Borders, and Technical book stores.

Some of the past tips from UGU can also be seen in the book.

http://www.amazon.com/exec/obidos/ASIN/0789719274/unixguruuniverse

Here are what some UGU'ers are saying about the book:
-----------------------------------------------------
mikec@sficorp.com from Green Bay, WI , August 21, 1999
FANTASTIC - FIVE STARS *****
This is a great book for those looking for quick solutions to common real work scenarios. If you are responsible for Unix (yes including Linux) systems this is one book you have to have. For coding solutions the book usually shows both shell script and perl examples for the same problem

jbaduria@hotmail.com from San Mateo, CA, USA , August 19, 1999
GREAT BOOK!! - FIVE STARS *****
Finally a book that deals with the real things that most UNIX system administrators face. It saves you the trouble of finding out things only after you face it. You could save yourself a lot of time solving problems that could have been avoided by reading this book. With the price nothing beats it. Not even those $30+ books.

link2000@n-link.com from Tx, Usa , June 25, 1999
GREAT BOOK - FIVE STARS *****
This is a great book. It has many tricks that are geared toward real world experience that are not covered in any other book I have seen. I especially liked the section geared toward getting your first job as an system admin. It is one book worth buying. For all kinds of information for less than 15 dollars how could you go wrong.


--------------------------------------------------------------------------
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 Oktober 2009

Unix Tip: REPETITIVE TASKS WITH XARGS

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3182 - October 23, 2009

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

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


REPETITIVE TASKS WITH XARGS

Save yourself a lot of typing when you have to perform repetitive commands on a list of files. Put the list of files in a text file with one file per line ie: find . -name version.C > filename Then have xargs build a command line for each file in the list as follows:

cat filename |xargs -n 1 cp anotherfile

This will copy anotherfile over all the files listed in filename one at a time until the end of filename is reached.


--------------------------------------------------------------------------
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 Oktober 2009

Unix Tip: Suppose we want to check whether the web server is running or

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3181 - October 22, 2009

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

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


Suppose we want to check whether the web server is running or not, but we don't have any browsers ( lynx, IE, Netscape ...), then there is a simple way of doing that. Just telnet to that machine on the http port ( port no 80 in general).

% telnet <ip addr> <port no>

And then, say "get /" (without quotes). If the webserver is running, it displays the HTML script of the homepage or basic info and closes the connection to the remote host.

% telnet yahoo.com 80
Trying 204.71.200.245...
Connected to yahoo.com.
Escape character is '^]'.
get /
HTTP/1.0 302 RD
Location: http://www.yahoo.com/

Connection closed by foreign host.

--------------------------------------------------------------------------
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 Oktober 2009

Unix Tip: CTRL-D ANOTHER USE

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3180 - October 21, 2009

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

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


CTRL-D ANOTHER USE

Many Unix Admins use the C shell as their interactive shell. An often used feature of Csh is file completion - initiated with 'set filec'. It allows the Csh user to type in partial file names, and then press escape to get them completed where possible. A little known side effect of this is that Control-D (^D) will now generate file listings in the middle of command lines.

Example 1: (where @ is a space)
host > @^D
Lists the current directory

Example 2:
host >ln -s /usr/^D
Lists the /usr directory

host >tar cvf /dev/nrtape /usr/m^D
Lists all m* files in the /usr directory

In each case, after the listing, you get a new command line and are placed at the last point of edit.

Very handy if you you know what you wanted to do but forgot what you wanted to do it with!


This tip generously supported by: mikal.dunn@halliburton.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, 20 Oktober 2009

Unix Tip: HIDE THOSE FILES

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3179 - October 20, 2009

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

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


HIDE THOSE FILES

If you want to have some hidden directories on your server (warez etc.) then make a directory with permission 111.


% chmod 111 foo/

All the contents will become hidden:

% cd foo
% ls -al
Cannot access directory .: Permission denied

The directory will have to opened back up (755) in order to see or access the files or the directory. To remove the directory and its contents, it will also need to have the permissions opened.


--------------------------------------------------------------------------
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 Oktober 2009

Unix Tip: PERFORMANCE OF CROND TASKS

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3177 - October 18, 2009

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

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


PERFORMANCE OF CROND TASKS

A good tip for getting better performance in crond tasks is choosing a better time for launching them.

If the process that we want to launch needs few time, but can overload the system easily, you can launch the task in hours that the work is busy and -and HERE is the tip- in strange minutes. That's why lots of people launch their crons at midnight, but nobody uses to do it at 00:13, in example.

That tip can obtain his best in hourly-launched tasks. If that kind of tasks are launched all at the same time, the system will overload without any use. You can delay that kind of tasks (one at 13th minute, other at 17th minute,other at 27th minute...) and obtain better performance without work. That will avoid overloading caused by launching several tasks at the same time.

The best is that administration tasks do not overlap, but this is not always possible. If you can do it, it's better you do it.

Using nice is also a good idea.

But the best is making a log of the uptime during a week. You can be surprise, because all the staff of a department of a firm use to do the coffee-break at the same time; it's the perfect time for making some administrative tasks. :-)

But do not clear the forbidden extensions -the famous find /home -name core -exec \{\} \; and other stuff like tmps, ~s and so on- of the system at work time, or you will have a queue of staff people very, very angry knocking at your door.


This tip generously supported by: irbis@activanet.es


--------------------------------------------------------------------------
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 Oktober 2009

Unix Tip: SHELL SCRIPTING A SQLPLUS SCRIPT

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3176 - October 17, 2009

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

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


SHELL SCRIPTING A SQLPLUS SCRIPT


Here is a tip on how to run sqlplus scripts within a shell script. It is an example of how to pass database values into shell variables and to make shell scripts more dynamic. This maybe elementary to some folks but hope it helps others.....Here is the syntax:

#!/bin/sh
dummyvar=`sqlplus -s username/password <<end
set pagesize 0 feedback off ver off heading off echo off
select sysdate from dual;
exit;
end`
echo "system date is " $dummyvar

Jumat, 16 Oktober 2009

Unix Tip: I SEE YOU WITH FUSER

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3175 - October 16, 2009

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

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


I SEE YOU WITH FUSER

In System V, you can use the following command to see who is accessing a particular file system:

fuser <file system>

For example, to see who is accessing the /cdrom directory:

fuser /cdrom

This command is useful if you wish to unmount a file system but the system is unable to do so because it is being used.


This tip generously supported by: anthony-leong@usa.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
==========================================================================

Kamis, 15 Oktober 2009

Unix Tip: GLOBAL SYSTEM PATH SETTINGS

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3174 - October 15, 2009

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

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


GLOBAL SYSTEM PATH SETTINGS

Cross-Platform System Administration Tip

If you want to set a system path that will apply to all users, regardless of which shell they use, edit the following file:

For Solaris: /etc/default/login
For HP-UX: /etc/PATH
For AIX: /etc/environment


--------------------------------------------------------------------------
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 Oktober 2009

Unix Tip: KILLING ALL USER PROCESSES

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3173 - October 14, 2009

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

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


KILLING ALL USER PROCESSES

The common method for killing all of a users processes usually involves grepping the users name from 'ps', then using awk to get the process id's and submitting them to 'kill -9'.

Sys V
ex: kill -9 $(ps -fuusername | awk '{ print $2 }' )

BSDish
ex: kill -9 $(ps -aux |grep username | awk '{ print $2 }' )

The problems with doing this way are that it is slow, and more importantly, it doesn't always kill all of the processes on the first try.

There is a way to do this that always kills all of the users processes the first time, and is very fast:

su - username -c 'kill -9 -1'


This tip generously supported by: jkstill@teleport.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, 13 Oktober 2009

Unix Tip: NFS HANG FIX ON HP-UX

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3172 - October 13, 2009

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

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


NFS HANG FIX ON HP-UX

In an NFS environment (Hp-UX based), sometimes no user is able to log-in when home directories are mounted using automounter). As user validation occurs, the user .profile is executed but no shell prompt appears unless the user presses CTRL-C.

The Solution to this is to kill the portmap & inetd and restart the two daemons. The problem will then be sorted out.


This tip generously supported by: sgogia@hss.hns.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
==========================================================================

Senin, 12 Oktober 2009

Unix Tip: REGEXP MATCHING IN AWK

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3171 - October 12, 2009

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

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


REGEXP MATCHING IN AWK

If you ever find yourself typing "command | grep pattern | awk '{print $3}' you can shorten this by using the regexp matching in awk, like this:

command | awk '/pattern/{print $3}'


--------------------------------------------------------------------------
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 Oktober 2009

Unix Tip: Public Relations

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3170 - October 11, 2009

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

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


Public Relations

One of the best things an admin can do is to have good public relations with the user community.

Don't just be there when problems arise. Go out to the user community when things are working. High visibility is the key.

If the users see you around and there are no problems they will believe that you care to take the time for them.

Try not to let the users always go come to you.

Go to those users that you never here from The perfect users, the ones that leave you alone. Often the don't have an understanding of what you can do for them.

I know many will say, "I don't have time!" Just a calm walk through a department is really all it takes, sometimes you never have to stop.

--------------------------------------------------------------------------
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 Oktober 2009

Unix Tip: CLEANUP AT LOGOUT

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3169 - October 10, 2009

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

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


CLEANUP AT LOGOUT

The following c-shell .logout script will clear your Netscape cache. No action will be taken if Netscape is current running.

------------------- CUT HERE ------------------------------
#!/bin/csh

if !( `ps -eu $USER | grep netscape | grep -v grep | sed -e 's/^ *//' -e 's/ .*//'` ) then
echo
echo "Clearing Netscape cache..."
\rm -rf ~/.netscape/cache/*
endif

echo
echo "Exiting..."

------------------- CUT HERE ------------------------------
This tip generously supported by: rb237@phy.cam.ac.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, 08 Oktober 2009

Unix Tip: AWK QUICK COLUMNS

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3167 - October 8, 2009

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

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


AWK QUICK COLUMNS

Most of the time when you use awk from the command line, you're doing something simple like this:

ps -ef | grep netscape | awk '{print $2}'

To save typing, use this script when you only want to use awk to print out one or more columns:

------------------- CUT HERE ---------------------------
#!/bin/ksh
# awkc - print out one or more columns

p=\$$( echo $1 | sed 's/,/,\$/g' )
shift
eval "awk '{ print $p }'" $*

# eof
------------------- CUT HERE ---------------------------

Now you can do things like:
ps -ef | awkc 2,1
or
awkc 1,2,3 /var/adm/messages*

This tip generously supported by: kbeer@dbna.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, 04 Oktober 2009

Unix Tip: ALTERNATIVE TO CP

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3163 - October 4, 2009

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

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


ALTERNATIVE TO CP

Define the following alias:

tar cvf - . | ( cd \!* ; tar xvf - )

or as an alias:

alias cpbytar 'tar cvf - . | ( cd \!* ; tar xvf - )'
(The alias definition above is for CSH)

To do a recursive copy of a directory to another location, preserving the PERMISSIONS and OWNERSHIP of the files. "cd" to the source location and invoke the following alias

cpbytar <destination_directory>

This tip generously supported by: bhavin@informix.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 Oktober 2009

Unix Tip: -------- REMOVE THE DASHES

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3162 - October 3, 2009

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

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


-------- REMOVE THE DASHES

Have you ever accidentally created a file beginning with '-'? It happens often by mistake and from the first look it seems like you can't delete the file (rm thinks the initial - is an option, and doesn't recognize the file).

The simple, quick way around this is the -- option to rm. Say you had the file ---hey in the current directory:

$ ls ---hey

/bin/ls: unrecognized option `---hey'
Try `/bin/ls --help' for more information.

$ ls|grep hey
---hey

$ rm ---hey
rm: unrecognized option `---hey'

Try `rm --help' for more information.
$ rm -- ---hey

( ls also has an -- option: )

$ ls -- ---hey
/bin/ls: ---hey: No such file or directory
$

This tip generously supported by: root@analog.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
==========================================================================

Jumat, 02 Oktober 2009

Unix Tip: SEPARATE SHELL COMMAND HISTORY FILES

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3161 - October 2, 2009

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

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


SEPARATE SHELL COMMAND HISTORY FILES

In any X based desktop when the number of pseudo terminal windows are more then one, the common shell history file (KSH) becomes a nuisance. Here is a way to have separate, safe and limited shell command history files.

Put the following code in your shell RC file.

--------------------------------CODE START------------------------------------
# Form a unique name for the shell history file using the tty output and
# set the shell variable HISTFILE to point to that
# This solves the problem of mutiple shells using the same history file
# and causing the confusion....
histf=`tty | awk 'BEGIN {FS="/"; nm=".shist_"} { for (i=1; i<=NF; i++) nm = nm
$i;} END { print nm;} '`
export HISTFILE=$histf
\rm -f $histf
echo History file is $histf...
--------------------------------CODE END------------------------------------

This tip generously supported by: atulk@informix.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
==========================================================================

Kamis, 01 Oktober 2009

Unix Tip: SHARING STDIN/STDOUT ON 2 TERMINALS

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3160 - October 1, 2009

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

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


SHARING STDIN/STDOUT ON 2 TERMINALS


Ever wanted the standard input and standard output to be shared on two terminals?

Try the following short script,

------------------- CUT HERE -------------------------

[ $# -lt 2 ] && echo "Usage: $0 program ttytodupon" && exit 2
mytty=`tty`
prog=$1
othertty=$2
sh -c "$prog|tee -a $mytty" 1>$othertty 2>&1 0>$othertty

------------------- CUT HERE -------------------------
This tip generously supported by: ian@kiwiplan.co.nz

--------------------------------------------------------------------------
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, 29 September 2009

Unix Tip: MULTI-SYSADMIN MONITORING

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

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3158 - September 29, 2009

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

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


MULTI-SYSADMIN MONITORING

To can see what someone logged in as root is running, if root's shell uses .sh_history ( ksh, for example ) do:

# tail -f /.sh_history

This is good in multi-Sysadm environments when you want to get an idea of what another admin is doing to fix something.

--------------------------------------------------------------------------
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