A thread dedicated to those useful Unix commands we all know and love. Ya right.
I need a really tricky find command the other day so I came up with the following. I wanted to save the command some where as it really shows the power of find
Find all files that are not in the [...]
I just helped a friend out with placing a shell variable into a sed command and thought it would be prudent to document it.
This set of commands was to be used to change directory names inside a samba share, hense the directory names of \ and the unix escape needed making a bunch of \\ [...]
Add the following to your .kshrc or .bashrc files.
# KSH terminal headers add to .profile
PS1=`uname -n`” $ ”
alias cd=_cd
function _cd {
\cd ${1+”$@”} && echo “\033]0;${USER}@${HOST}: ${PWD}\007\c”
}
# BASH terminal headers add to .bashrc
PROMPT_COMMAND=’echo -ne “\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007″‘
# PS1=’\h] \w\$ ‘ #simple prompt with hostname and current path
PS1=’\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]‘ #color prompt
KSH script to check the number of processes on a system and send an email if there are too many.
I liked this as it was simple, but had some nice elements that could be used elsewhere.
#!/bin/ksh
#
# Script to check for run away ftp processes.
# 04/08 – Mike Byers
HOST=`uname -n`
ADMINZ=”admin@somewhere.com”
# Add email Recipients
RECPTS=”email_add@somewhere.com”
# Let the user [...]
So you want to change some text in many unix files.
Try the following.
perl -pi -e ’s/find/replace/g’ *.txt
or to script it out.
Find the TEXT in regular files and replace with NEWTEXT
for file in `find ./ -type f -exec grep -l TEXT {} \;`
do
perl -pi -e ’s/TEXT/NEWTEXT/g’ $file
done