Revision [4093]

Last edited on 2011-08-10 23:01:35 by KenFong
Additions:
[[BashGetOpt Options processing with getopt]]
-----


Revision [3861]

Edited on 2010-10-12 20:34:08 by KenFong
Additions:
sed -i.bak -e 's/Today/Yesterday/g' some_file.txt
Deletions:
sed -i.bak "s/Today/Yesterday/g" some_file.txt


Revision [3810]

Edited on 2010-08-26 22:10:06 by KenFong
Additions:
===sed===
Inline editing
sed -i.bak "s/Today/Yesterday/g" some_file.txt


Revision [3619]

Edited on 2010-01-25 00:23:27 by WikiAdmin
Additions:
===Bash stuff===
==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 WikiAdmin
Additions:
===awk===
awk -F: '($3 == "0") {print}' /etc/passwd


Revision [3536]

Edited on 2009-10-05 23:00:23 by WikiAdmin
Additions:
===Remove carriage returns===
echo $text | tr -d '\n'


Revision [3529]

Edited on 2009-09-25 08:43:18 by WikiAdmin
Additions:
function myfunc()
{
local myresult='some value'
echo "$myresult"
result=$(myfunc)
echo $result


Revision [3453]

Edited on 2009-07-26 23:33:06 by WikiAdmin
Additions:
==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 "


Revision [2287]

Edited on 2009-04-20 23:50:07 by WikiAdmin
Additions:
===Parameter Expansion===
JAVA_HOME=${JAVA_HOME:-"/usr/java/latest"}


Revision [2199]

Edited on 2009-02-12 09:02:17 by WikiAdmin
Additions:
==for loop ==
==if then else==
== Text parsing ==
== bash array and loops==
==real example 1 ==
Deletions:
=== for loop ===
===if then else===
=== Text parsing ===
=== bash array and loops===
=== real example 1 ===
done%%


Revision [2198]

Edited on 2009-02-12 09:01:19 by WikiAdmin
Additions:
===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
Deletions:
===bash shortcuts===
===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 WikiAdmin
Deletions:
{{table columns="2" cellpadding="1" cells="header1;header2;cell1;cell2"}}


Revision [1555]

Edited on 2008-03-26 08:34:35 by WikiAdmin
Additions:
""
Deletions:
""


Revision [1554]

Edited on 2008-03-26 08:34:07 by WikiAdmin
Additions:
{{table columns="2" cellpadding="1" cells="header1;header2;cell1;cell2"}}
Deletions:
|| ^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||
||^r|| Recall last command in history, starting with charcters provided||
||^k|| Delete line||
||^w|| Delete word||
||^y|| Undo deletion||
||^l|| Clear screen||


Revision [1553]

Edited on 2008-03-26 08:33:45 by WikiAdmin
Additions:
""





Deletions:
""
^r Go to end of line
^k Delete line
^w Delete word
^yUndo deletion
^l Clear screen


Revision [1552]

Edited on 2008-03-26 08:32:14 by WikiAdmin
Additions:
""





^aGo to beginning of line
^a, alt-lGo to beginning of line, and change all letters to lower case
alt-cChange line to lower case
^e Go to end of line
""


Revision [1548]

Edited on 2008-03-26 08:21:04 by WikiAdmin
Deletions:
{{table columns="2" cellpadding="1" cells="header1;header2;cell1;cell2"}}


Revision [1547]

Edited on 2008-03-26 08:20:30 by WikiAdmin
Additions:
{{table columns="2" cellpadding="1" cells="header1;header2;cell1;cell2"}}


Revision [1546]

Edited on 2008-03-26 08:19:27 by WikiAdmin
Additions:
|| ^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"
Deletions:
||^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"


Revision [1474]

The oldest known version of this page was created on 2008-03-10 03:22:11 by WikiAdmin
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki