April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

48 TIPS FOR BASH

We collected a bunch of shell scripting skills, I said, I write a blog mainly to make some study notes, to facilitate their access to,

so I would come up with such an article, there is no incomprehensible. About the origin of these skills, eh, I forgot, it may come from theunixschool, commandlinefu, cool ground […]

sed example

Text Interval: ——–

# Add a blank line after each line sed G

# The original delete all blank lines and add a blank line after each line. # So that each line of text output later and only a blank line. sed ‘/ ^ $ / d; G’

# […]

Bash Reference Sheet

Bash Reference Sheet

Contents Bash Reference Sheet Syntax Basic Structures Compound Commands Command Lists Expressions Loops Builtins Dummies Declarative Input Output Execution Jobs/Processes Conditionals And Loops Script Arguments Streams File Descriptors Redirection Piping Expansions Common Combinations Tests Exit Codes Testing The Exit Code Patterns Glob Syntax Testing Parameters Special Parameters Parameter Operations Arrays Creating Arrays […]

Unix commands helps

grep grep is a saviour command for unix users. grep can be used to search for patterns in a file or standard input. The pattern search includes finding the line number of the keyword, counting the number of occurrences of a keyword and many more. we will see in the following examples.

Example 1) grep […]

IFS – Internal Field Separator

It seems like an esoteric concept, but it’s actually very useful.

If your input file is “1 apple steve@example.com”, then your script could say:

while read qty product customer do echo “${customer} wants ${qty} ${product}(s)” done The read command will read in the three variables, because they’re spaced out from each other.

However, critical data […]

cheat.sheet FOR AWK SED PERL and VI

[gview file=”http://rmohan.com/wp-content/uploads/2014/08/awk.cheat_.sheet_.pdf”]

 

[gview file=”http://rmohan.com/wp-content/uploads/2014/08/bash-history-cheat-sheet.pdf”] [gview file=”http://rmohan.com/wp-content/uploads/2014/08/bash-vi-editing-mode-cheat-sheet.pdf”] [gview file=”http://rmohan.com/wp-content/uploads/2014/08/perl.predefined.variables.pdf”] [gview file=”http://rmohan.com/wp-content/uploads/2014/08/sed.stream.editor.cheat_.sheet_.pdf”]

awk.cheat

.———————————————————————–. | | | AWK Cheat Sheet | | | ‘———————————————————————–‘ | Peteris Krumins (peter@catonmat.net), 2007.08.22 | | http://www.catonmat.net – good coders code, great reuse | ‘———————————————————————–‘ ===================== Predefined Variable Summary ===================== .————-+———————————–.———————. | | | Support: | | Variable | Description ‘—–.——-.——-‘ | | | AWK | NAWK | GAWK | ‘————-+———————————–+—–+——-+——-‘ | FS […]

shell samples

awk examples

cat 03092608.LOG|grep XYZ|awk -F”.” ‘{print $2}’ |sort|awk ‘{tot += 1 } $1 != prev {print prev,tot;tot=0;prev=$1}END{print prev,tot;tot=0;prev=$1}’

adhocs

1. find_processes_using_ipcs.ksh

 

ipcs -bop|grep `whoami`|awk ‘{print $10}’|egrep -v “^0|^$”|sort -u|awk ‘{print “ps -ef|grep “, $1}’|ksh

2. iostat iostat -xn 4 30 3. jmap jmap -heap:format=b <pid> 4. monitorMemLeaking if [ $# […]

top_thread of Java

# put your JAVA_HOME here, JAVA_HOME=/opt/javavm PID=$1 IFS=” top_number=10 if[ $# -gt 1 ] ; then top_number=$2 fi top_number=$((top_number+1)) java_stack=`$JAVA_HOME/bin/jstack $PID` top=`top -s -b -H -p $PID -n 1 | grep -vE ‘^top|^Tasks|^Cpu|^Mem|^Swap|^$’ | awk ‘NR==1; NR > 1 {print $0 | “sort -nrk 9”}’ | head -$top_number` echo $top echo $top |while read […]

bash analyze ports and pids

# put your JAVA_HOME here, JAVA_HOME=/opt/javavm PID=$1 IFS=” top_number=10 if[ $# -gt 1 ] ; then top_number=$2 fi top_number=$((top_number+1)) java_stack=`$JAVA_HOME/bin/jstack $PID` top=`top -s -b -H -p $PID -n 1 | grep -vE ‘^top|^Tasks|^Cpu|^Mem|^Swap|^$’ | awk ‘NR==1; NR > 1 {print $0 | “sort -nrk 9”}’ | head -$top_number` echo $top echo $top |while read […]