Sie sind auf Seite 1von 4

http://www.linuxconfig.org/Grep_egrep_fgrep_rgrep ***http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.

html #To view just the uncommented lines of text in a config file use grep, sed , awk , perl or any other text processing utility provided by UNIX / BSD / Linux syste ms. #GNU grep example: $ grep -v "^#" /path/to/config/file $ grep -v "^#" /etc/apache2/apache2.conf egrep -in "dilip .php" xferlog cat xferlog grep "dilip$" grep ".php$" less

#GNU sed example: $ sed '/ *#/d; /^ *$/d' /path/to/file $ sed '/ *#/d; /^ *$/d' /etc/apache2/apache2.conf # egrep -v ^# ^$ /etc/httpd/conf/httpd.conf grep -v ^# httpd.conf cat -s cat names sed 's/MA/Massachusetts/; s/CA/California/' #By using the 's' substitution command, we can substitute one string of characte rs with another. The 's' command takes two arguments delimited by '/' characters . What you are searching for goes in the first / / area and the second / / is th e string that you want to replace it with. In this example, we substitute the tw o letter state abbreviations for MA and CA with their full name: cat names sed 's/ \([A-Z]\{2\}\)$/, \1/' #The expression contains a few concepts that have been stated before but I will go over again. The first noticeable one is the use of the \( \) sequence. This w ill "remember" whatever is placed inside so that you can use it in the replacing expression. According to how many \( \) you used, you will need to use \1, \2, \3 and so on in the replacement expression. The second thing is the character set [A-Z]. The [] expression means match any s ingle character in that set. The A-Z part means that the set includes all charac ters from A through Z. Note, this is case sensitive and a-z will not match the s ame set of characters that A-Z will. If you just put [AZ] in, it will only match A or Z, not B, C, D, E, ... , W, X or Y. The third part of the expression is the \{2\} part. This simply means the match must have 2 of the previous expression. The $ character at the end of the matchi ng expression matches the end of the line. Together this all means, match a space followed by exactly 2 characters that are from A through Z and are at the end of the line. In this file, as long as the f ormat remains the same, it will only match the last field containing the state's abbreviation following the city name. So it is relatively easy to add the comma between those two fields. ------------------------------------------------------------#awk syntax works like this, you give the command awk, then any options you want to use with it followed by curly braces containing the commands that you want t o run on the input. Like this: $ awk -F: {'print $1 " " $2'} #Note that the $1 used in the curly braces is not the $1 that bash uses to signi fy the first argument passed to a script. This is an important difference to rea

lize if you ever start using awk within scripts that take arguments. tail access_log awk {'print $1'} #By default awk will split fields of a line on a space character, so if we add m ore elements to the print statement for awk it will print the respective rows: tail access_log awk {'print $1 " " $9 " " $10'} ./QmailLogSearch.sh -l maillog.old -f ronwilliams@blayson.com -t ptk@kilachand.c om -- for searching qmail-logs ./QmailLogSearch.sh -l maillog -f amber.smith@perrigo.com -t vijay@embio.co.in qmailctl stat -- for getting qmail mailq qmailctl flush qmailctl stat postcat transport -- for restarting transport file after changes #For Ldap Search /usr/local/ldap/bin/ldapsearch -h 202.87.39.4 -b "o=exmit.moc" "uid=mailadmin.c harak" /usr/local/ldap/bin/ldapsearch -h 202.87.39.4 -b "o=exmit.moc" "uid=Vijay.embio .co.in*" #Check Maillog ls -lrt maillog* head -1 maillog tail -f /var/log/maillog mailq less for i in `cat 1` ; do ll $i/.qmail-* >> 3 ; done for i in `cat 1` ; do ll $i/Users/ >> 4 ; done cat 3 awk '{print $9}' cut -d "-" -f1 sort dmesg dmesg dmesg dmesg dmesg grep CPU less grep intel grep Intel less less

uniq

wc -l

dmidecode

#Mail Scanner stop/start/status /etc/init.d/MailScanner stop / start /status postcat EFC7247D7DA postcat -q EFC7247D7DA sh -x /tmp/dddd mailq wc -l mailq less postfix flush less

#check mailq and delete mailq grep root mailq grep root grep "Jan" mailq grep root grep "Jan" vim /tmp/delme vim /etc/inittab kill -1 1 sh -x /tmp/delme

awk {'print $6'} > /tmp/delme

#scan /check maillog specified tail -f /var/log/maillog grep "NOQUEUE" tail -f /var/log/maillog grep -v "NOQUEUE" tail -f /var/log/maillog grep "status=sent" tail -f /var/log/maillog grep "status=sent" mailq grep "afaqsnewsletter.com" mailq grep "afaqsnewsletter.com" wc -l vi relay_domains vi transport postmap transport

awk {'print $9'} awk {'print $9'}

#fetch user details sh -x /scripts/FetchAllUsers.sh --ignore-deletes cat maillog grep "Jan 6" > mailllog.6thJan09 tail -f /var/log/maillog grep "status=sent" awk {'print $9'} #check Mailq specified details cd /etc/MailScanner mailq grep "medianews@afaqsnewsletter.com" mailq grep -B2 "medianews@afaqsnewsletter.com" l mailq grep -B2 "medianews@afaqsnewsletter.com" {'print $1'} > /tmp/delme

grep "MAILER-DAEMON" grep "MAILER-DAEMON"

wc awk

#findlog.sh #!/bin/bash for i in `cat maillog-list` do zcat $i egrep -ie "cellebrum.com modicorp.com spicetelecom.com" awk '{print $6 }' sort uniq >> $i-ids zcat $i grep -i "from=<Saleem@hungama.com>" awk '{print $6}' sort uniq >> $i-saleem-ids comm -12 $i-ids $i-saleem-ids >> $i-comm-ids for j in `cat $i-comm-ids` do cat $i grep -i "$j" >> $i-logs done done #DNS: /var/named/forward rndc reload <domain-name> -- after changes done on the domain forward files Backups: updatedb -- for chaecking db for any duplicate entries bat -c /ysr/local/bacula/etc/bat.conf -- to restart the backup job /usr/local/bacula/bin/bacula_tray_monitor -c /usr/local/bacula/etc/tray.monitor. conf & -- to monitor backup jobs /usr/local/backup/script ./change_job_partition.sh -- to change the partition type 'cancel' in the commoand to cancel the job #For Restoration:

#Get the details from bacula webclient from the below backup/internal ip Server : 123.108.39.51/ 10.150.1.16 #for e.g: the sandisk, the volumes, starttime sandisk4 - Vol0540 Vol0072 Vol0221 - Start time: 03-Jan-2010 22:00:0 2 #login to the Graphical mode of bacula server for e.g.: sakibackula1 #then type <ctrl>r #type ((reverse-i-search)`bwx': /usr/local/bacula/bin/bwx-console -c /usr/local/ bacula/etc/bwx-console.conf &) bwx <enter> #Go to Restore press <Enter Restore Mode>

Das könnte Ihnen auch gefallen