Revision [4093]
Last edited on 2011-08-10 23:01:35 by KenFongAdditions:
[[BashGetOpt Options processing with getopt]]
-----
-----
Revision [3861]
Edited on 2010-10-12 20:34:08 by KenFongAdditions:
sed -i.bak -e 's/Today/Yesterday/g' some_file.txt
Deletions:
Revision [3810]
Edited on 2010-08-26 22:10:06 by KenFongAdditions:
===sed===
Inline editing
sed -i.bak "s/Today/Yesterday/g" some_file.txt
Inline editing
sed -i.bak "s/Today/Yesterday/g" some_file.txt
Revision [3619]
Edited on 2010-01-25 00:23:27 by WikiAdminAdditions:
===Bash stuff===
==Bash array and for loop==
DIRS[0]=one
DIRS[1]=two
DIRS[2]=three
for d in ${DIRS[@]}
echo $d
==Bash array and for loop==
DIRS[0]=one
DIRS[1]=two
DIRS[2]=three
for d in ${DIRS[@]}
echo $d
Revision [3567]
Edited on 2009-10-30 19:34:35 by WikiAdminAdditions:
===awk===
awk -F: '($3 == "0") {print}' /etc/passwd
awk -F: '($3 == "0") {print}' /etc/passwd
Revision [3536]
Edited on 2009-10-05 23:00:23 by WikiAdminAdditions:
===Remove carriage returns===
echo $text | tr -d '\n'
echo $text | tr -d '\n'
Revision [3529]
Edited on 2009-09-25 08:43:18 by WikiAdminAdditions:
function myfunc()
{
local myresult='some value'
echo "$myresult"
result=$(myfunc)
echo $result
{
local myresult='some value'
echo "$myresult"
result=$(myfunc)
echo $result
Revision [3453]
Edited on 2009-07-26 23:33:06 by WikiAdminAdditions:
==enable history timestamp==
Save this in /etc/bashrc, this will enable timestamp display with the history command
export HISTTIMEFORMAT="%Y-%h-%d - %H:%M:%S "
Save this in /etc/bashrc, this will enable timestamp display with the history command
export HISTTIMEFORMAT="%Y-%h-%d - %H:%M:%S "
Revision [2287]
Edited on 2009-04-20 23:50:07 by WikiAdminAdditions:
===Parameter Expansion===
JAVA_HOME=${JAVA_HOME:-"/usr/java/latest"}
JAVA_HOME=${JAVA_HOME:-"/usr/java/latest"}
Revision [2199]
Edited on 2009-02-12 09:02:17 by WikiAdminAdditions:
==for loop ==
==if then else==
== Text parsing ==
== bash array and loops==
==real example 1 ==
==if then else==
== Text parsing ==
== bash array and loops==
==real example 1 ==
Deletions:
===if then else===
=== Text parsing ===
=== bash array and loops===
=== real example 1 ===
done%%
Revision [2198]
Edited on 2009-02-12 09:01:19 by WikiAdminAdditions:
===Bash===
CHeck out bash4 http://www.bash-hackers.org/wiki/doku.php/bash4
==bash shortcuts==
==bash prompt==
== Case switch ==
== Function and variables ==
== Compare floating point numbers ==
== Read input, if then else ==
echo "To disable forward, type DISABLE. Default is null in 10seconds"
read -t10 fw
CHeck out bash4 http://www.bash-hackers.org/wiki/doku.php/bash4
==bash shortcuts==
==bash prompt==
== Case switch ==
== Function and variables ==
== Compare floating point numbers ==
== Read input, if then else ==
echo "To disable forward, type DISABLE. Default is null in 10seconds"
read -t10 fw
Deletions:
===bash prompt===
=== Case switch ===
=== Function and variables ===
=== Compare floating point numbers ===
=== Read input, if then else ===
echo "To disable forward, type DISABLE"
read fw
Revision [1556]
Edited on 2008-03-26 08:34:59 by WikiAdminDeletions:
Revision [1555]
Edited on 2008-03-26 08:34:35 by WikiAdminAdditions:
""
| ^r | Go to end of line |
| ^k | Delete line |
| ^w | Delete word |
| ^y | Undo deletion |
| ^l | Clear screen |
| ^a | Go to beginning of line |
| ^a, alt-l | Go to beginning of line, and change all letters to lower case |
| alt-c | Change line to lower case |
| ^e | Go to end of line |
Revision [1548]
Edited on 2008-03-26 08:21:04 by WikiAdminDeletions:
Revision [1547]
Edited on 2008-03-26 08:20:30 by WikiAdminAdditions:
{{table columns="2" cellpadding="1" cells="header1;header2;cell1;cell2"}}
Revision [1546]
Edited on 2008-03-26 08:19:27 by WikiAdminAdditions:
|| ^a || Go to beginning of line||
eval "$1=\"xxx\""
echo ${PATH[$i]}
find ${PATH[$i]} ! -name "*.zip" -mtime +31 | xargs zip -m ${PATH[$i]}/logs-$DATESTR.zip
IP=`host "$1" | awk '{print $4}' | sed s/found\:/NOT_FOUND/g`
if [ ${#IP} -lt 2 ]; then
# no record found
echo -n "NOT_FOUND"
else
echo -n $IP
fi
MX=`host -tmx "$1" | grep handled | grep -v datapipe | awk '{print $7}' | sed '$!N;s/\n/\//g'`
if [ ${#MX} -lt 2 ]; then
# no MX record found
echo NONE
else
# get IP address for each MX record
MXIP=`host "$MX" | awk '{print $4}' | sed s/found\:/NOT_FOUND/g`
echo "$MX ($MXIP)"
fi
d=`echo $f | awk 'BEGIN {FS=","} {print $1}'`
echo -n $f
getip "$d"
echo -n ","
getmx "$d"
eval "$1=\"xxx\""
echo ${PATH[$i]}
find ${PATH[$i]} ! -name "*.zip" -mtime +31 | xargs zip -m ${PATH[$i]}/logs-$DATESTR.zip
IP=`host "$1" | awk '{print $4}' | sed s/found\:/NOT_FOUND/g`
if [ ${#IP} -lt 2 ]; then
# no record found
echo -n "NOT_FOUND"
else
echo -n $IP
fi
MX=`host -tmx "$1" | grep handled | grep -v datapipe | awk '{print $7}' | sed '$!N;s/\n/\//g'`
if [ ${#MX} -lt 2 ]; then
# no MX record found
echo NONE
else
# get IP address for each MX record
MXIP=`host "$MX" | awk '{print $4}' | sed s/found\:/NOT_FOUND/g`
echo "$MX ($MXIP)"
fi
d=`echo $f | awk 'BEGIN {FS=","} {print $1}'`
echo -n $f
getip "$d"
echo -n ","
getmx "$d"
Deletions:
eval "$1=\"xxx\""
echo ${PATH[$i]}
find ${PATH[$i]} ! -name "*.zip" -mtime +31 | xargs zip -m ${PATH[$i]}/logs-$DATESTR.zip
IP=`host "$1" | awk '{print $4}' | sed s/found\:/NOT_FOUND/g`
if [ ${#IP} -lt 2 ]; then
# no record found
echo -n "NOT_FOUND"
else
echo -n $IP
fi
MX=`host -tmx "$1" | grep handled | grep -v datapipe | awk '{print $7}' | sed '$!N;s/\n/\//g'`
if [ ${#MX} -lt 2 ]; then
# no MX record found
echo NONE
else
# get IP address for each MX record
MXIP=`host "$MX" | awk '{print $4}' | sed s/found\:/NOT_FOUND/g`
echo "$MX ($MXIP)"
fi
d=`echo $f | awk 'BEGIN {FS=","} {print $1}'`
echo -n $f
getip "$d"
echo -n ","
getmx "$d"