Tricky Things : 1

1. hange uppper/lower case character to anything

#  echo abc123ABC | sed -e 's;[[:upper:]]\{3\};TEST;'


2. print 10 minute before time using date command direcltly

# date --date="-10 minute" +'%H:%M:%S'

3. In case of log parsing, we always need the previous date . This command do print the previous date for you.

print previous date using date command:

# date --date="-1 Day" +'%d.%m.%Y %H:%M:%S'


4. Search within your range using awk - for example you are searching log of dated 20.06.2012 and time range is between 14:30 and 14:50

#  awk -v start='14:30' -v end='14:50' -v date='20.06.2012' 'date==$1 && end>=$2 && start<=$2' log.txt


5. If you want to run same command frequently withing a short interval e.g. TIME_WAIT connection in socket then "'watch" tool can be very useful:

# watch "netstat -na | greap ESTA | wc -l"

by default this command will run in every two seconds.

you can also specify the interval

# watch  --interval=2 "netstat -na | greap ESTA | wc -l"



6. We always use "tail -f" to see the live log in a file, we can simply use "tailf" which works like same way

# tailf /var/log/message

7. To remove any unbroken package from RPM DB:

#rpm --justdb -e package_name


8. To download pacakge from Oracle server using WGET where cookies need to be passed by the command:

#wget -c --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" "http://download.oracle.com/otn-pub/java/jdk/7u7-b10/jdk-7u7-linux-x64.tar.gz"  --output-document="jdk1.7.tar.gz"


9.  To avoid certificate error problem including with cookies when downloading the content from HTTPS site:

wget --no-check-certificate -c --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" "http://download.oracle.com/otn-pub/java/jdk/6u30-b12/jdk-6u30-linux-x64.bin"  --output-document="jdk-6u30-linux-x64.bin"


--2013-05-17 11:46:26--  http://download.oracle.com/otn-pub/java/jdk/6u30-b12/jdk-6u30-linux-x64.bin
Resolving www-proxy.lmc.ericsson.se... 142.133.17.203
Connecting to www-proxy.lmc.ericsson.se|142.133.17.203|:8080... connected.
Proxy request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/6u30-b12/jdk-6u30-linux-x64.bin [following]
--2013-05-17 11:46:27--  https://edelivery.oracle.com/otn-pub/java/jdk/6u30-b12/jdk-6u30-linux-x64.bin
Connecting to www-proxy.lmc.ericsson.se|142.133.17.203|:8080... connected.
WARNING: certificate common name “www.oracle.com” doesn’t match requested host name “edelivery.oracle.com”.
Proxy request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/6u30-b12/jdk-6u30-linux-x64.bin?AuthParam=1368805573_5429c58a6be2c088ba7fdcc785c3c393 [following]
--2013-05-17 11:46:27--  http://download.oracle.com/otn-pub/java/jdk/6u30-b12/jdk-6u30-linux-x64.bin?AuthParam=1368805573_5429c58a6be2c088ba7fdcc785c3c393
Connecting to www-proxy.lmc.ericsson.se|142.133.17.203|:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: 85570714 (82M) [application/octet-stream]
Saving to: “jdk-6u30-linux-x64.bin”

100%[====================================================================>] 85,570,714  1.32M/s   in 70s    

2013-05-17 11:47:37 (1.17 MB/s) - “jdk-6u30-linux-x64.bin” saved [85570714/85570714]
 

Comments

Popular Posts