修改gb2312网页编码为utf-8

Posted by 4Aiur on 01/10/2011 in Shell |

修改gb2312网页编码为utf-8 find html/ -type f -name “*.html” | \ while read line do mkdir -p foo/dirname $line/ iconv -f GB18030 -t UTF-8 $line 2>/dev/null | \ sed /charset=gb2312/’s/charset=gb2312/charset=utf-8/’ \ > foo/$line done

Tags:

不需要反引号的运行ssh复杂远程命令方式

Posted by 4Aiur on 06/07/2010 in Shell |

不需要反引号的运行ssh复杂远程命令方式 之前当我需要执行复杂的运程命令时,总是要先处理好引号、变量等问题,之后再执行命令写起来太麻烦,今天在commandlinefu上学了一招非常棒的方法,记录一下。 举个例子,之前需要用\反引$符号 [root@localhost ~]# ssh 127.0.0.1 -l root “echo a b c | awk ‘{print \$2}'” b 现在我们可以把复杂的命令写到文件中执行。 [root@localhost ~]# cat cmd echo a b c | awk ‘{print $2}’ 方法1: [root@localhost ~]# ssh 127.0.0.1 -l root “$( 方法2: [root@localhost ~]# ssh 127.0.0.1 -l root “cat cmd” b 方法3,使用标准输入执行,输入完毕后使用ctrl-D提交命令: [root@localhost ~]# ssh 127.0.0.1 -l […]

Tags: ,

查找使用中的文件与目录相关信息

Posted by 4Aiur on 05/10/2010 in SysAdmin |

查找使用中的文件与目录相关信息 以tmp目录为例,使用下面得方法获得使用tmp目录进程的相关信息。 [root@4aiur ~]# inode=stat -c %i tmp [root@4aiur ~]# cd tmp [root@4aiur ~]# lsof -n | awk -v a=$inode ‘a==$(NF-1) || a==$(NF-2)’ bash 1963 root cwd DIR 253,0 4096 23805953 /root/tmp lsof 2033 root cwd DIR 253,0 4096 23805953 /root/tmp awk 2034 root cwd DIR 253,0 4096 23805953 /root/tmp lsof 2035 root cwd DIR […]

Tags:

shell版按任意键继续

Posted by 4Aiur on 04/14/2010 in Shell |

按任意键继续的shell写法 read -sn1 -p “Press any key to continue…”; echo

Tags:

转换txt文件的字符编码

Posted by 4Aiur on 04/06/2010 in Shell |

转换txt文件的字符编码 find . -type f -name “*.txt” |\ while read line do if iconv -f GB2312 -t UTF-8 “$line” > /tmp/foo; then mv /tmp/foo “$line” else : fi done

Tags:

利用xargs实现多任务并发

Posted by 4Aiur on 04/06/2010 in Shell |

利用xargs实现多任务并发 [4aiur@localhost Temp]$ echo 127.0.0.1 192.168.2.50 192.168.10.108 | xargs -n1 -P2 -I % ping -c 3 % PING 127.0.0.1 (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.048 ms PING 192.168.2.50 (192.168.2.50): 56 data bytes 64 bytes from 192.168.2.50: icmp_seq=0 ttl=64 time=0.026 ms 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.091 ms 64 bytes […]

Tags:

Show File System Hierarchy

Posted by 4Aiur on 04/06/2010 in BSD, Linux |

Show File System Hierarchy $ man hier Curious about differences between /bin, /usr/bin, and /usr/local/bin? What should be in the /sbin dir? Try this command to find out. Tested against Red Hat & OS X

Tags:

目录名大小写转换

Posted by 4Aiur on 04/06/2010 in Shell |

使用find把目录名修改为大写——- find . -type d | sort -r |\ while read name do echo “mv $name ${name%/*}/echo ${name##*/} | tr '[:lower:]' '[:upper:]'” mv $name ${name%/*}/echo ${name##*/} | tr '[:lower:]' '[:upper:]' done 使用递归方式把目录名修改为小写 #!/bin/bash # set -x tolower () { ls | while read name do if [ -d $name ] ; then new_name=echo $name | […]

Tags:

使用多种方法打印50个连续的横杠

Posted by 4Aiur on 04/06/2010 in SysAdmin |

使用多种方法打印50个连续的横杠 python -c ‘print “-” * 50′ perl -le’print”-“x50’ awk ‘BEGIN{while (a++

Tags:

摘自www.commandlinefu.com的一些命令

Posted by 4Aiur on 04/06/2010 in Shell |

摘自www.commandlinefu.com的一些命令 # change to the previous working directory $ cd – # quickly backup or copy a file with bash $ cp filename{,.bak} # mtr, better than traceroute and ping combined # mtr combines the functionality of the traceroute and ping programs in a single network diagnostic tool. # As mtr starts, it investigates the […]

Tags:

Copyright © 2010-2024 4Aiur All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.