2013年4月11日 星期四

Convert date formats

[出處]
http://stackoverflow.com/questions/6508819/convert-date-formats-in-bash



Q:
I have a date in this format: "27 JUN 2011" and I want to convert it to 20110627
Is it possible to do in bash?




A:


#since this was yesterday
date -dyesterday +%Y%m%d

#more precise, and more reccomended
date -d'27 JUN 2011' +%Y%m%d

#assuming this is similiar to yesterdays `date` question from you 
#http://stackoverflow.com/q/6497525/638649
date -d'last-monday' +%Y%m%d

#going on @seth's comment you could do this
DATE = "27 jun 2011"; date -d"$DATE" +%Y%m%d

#or a method to read it from stdin
read -p "  Get date >> " DATE; printf "  AS YYYYMMDD format >> %s"  `date
-d"$DATE" +%Y%m%d`    

#which then outputs the following:
#Get date >> 27 june 2011   
#AS YYYYMMDD format >> 20110627

#if you really want to use awk
echo "27 june 2011" | awk '{print "date -d\""$1FS$2FS$3"\" +%Y%m%d"}' | bash

#note | bash just redirects awks output to the shell to be executed
#FS is field separator, in this case you can use $0 to print the line
#But this is useful if you have more than one date on a line





ASIX USB Ethernet Adapter (AX88178) not working with default module


# lsusb
Bus 002 Device 004: ID 0b95:1780 ASIX Electronics Corp. AX88178

# dmesg|grep -i ax88178

eth2: register 'asix' at usb-0000:00:1d.0-1.2, ASIX AX88178 USB 2.0 Ethernet, 00:11:6b:60:fa:a5
eth2: ax88178 - Link status is: 0
eth2: ax88178 - Link status is: 1

[症頭]
網卡已驅動成功,但封包傳送不出去....

[解決方法]
下載新的驅動程式
1. http://www.asix.com.tw/download.php
    Product Family: USB 2.0 to Gigabit Ethernet
    Product Name: AX88178

# tar -xf DRIVER_SOURCE_PACKAGE.tar.bz2
# make
# make install


========================================================================
ASIX AX88178 USB 2.0 Gigabit Ethernet Network Adapter
ASIX AX88772 USB 2.0 Fast Ethernet Network Adapter
ASIX AX88772A USB 2.0 Fast Ethernet Network Adapter
ASIX AX88760 USB 2.0 MTT HUB and USB 2.0 to Fast Ethernet Combo Controller
ASIX AX88772B USB 2.0 Fast Ethernet Network Adapter
ASIX AX88772C USB 2.0 Fast Ethernet Network Adapter
Driver Compilation & Configuration on the Linux
========================================================================
This driver has been verified on kernel versions from 2.6.14 to 3.8.0.




[參考]
http://linux.m2osw.com/asix-electronics-ax88178-driver
http://ubuntuforums.org/showthread.php?t=1480230