- 论坛徽章:
- 1
|
把@yestreenstars的代码稍微改一下就好了吧。那个awk写的挺牛逼的。- [root@localhost test]# cat txt | awk -F'[<>]' '{if($0~/CreateTime/){"date -d \042$(("substr($3,1,10)" - `date \047+%s\047` )) sec\042 +%Y-%m-%d" | getline s;printf "<%s>%s<%s>\n",$2,s,$4}else{print $0}}'
- <dc:creator>admin</dc:creator>
- <CreateTime>2014-01-19</CreateTime>
- <wp:post_id>40060814513</wp:post_id>
- <wp:post_type>post</wp:post_type>
- <wp:status>publish</wp:status>
- <category domain="post_tag">Something</category>
- <dc:creator>admin</dc:creator>
- <CreateTime>2014-01-18</CreateTime>
- <wp:post_id>40060794903</wp:post_id>
- <wp:post_type>post</wp:post_type>
- <wp:status>publish</wp:status>
- <category domain="post_tag">Something</category>
- <dc:creator>admin</dc:creator>
- <CreateTime>2014-01-12</CreateTime>
- <wp:post_id>40060756519</wp:post_id>
- <wp:post_type>post</wp:post_type>
- <wp:status>publish</wp:status>
- <category domain="post_tag">Something</category>
复制代码 |
|