找回密码
 注册
搜索
热搜: 回贴
微赢网络技术论坛 门户 服务器 Linux/BSD 查看内容

gonme下的kde和tr用于文件处理

2009-12-20 13:32| 发布者: admin| 查看: 22| 评论: 0|原作者: 小可爱

今天在使用konsole的时候,意外的发现,系统越用越慢。。。然后使用ps -aux看了一下,发现,有一个线程一直在自动增加。
yongtao 16066 0.0 1.0 25556 5160 ? Ss 11:09 0:00 kdeinit Running...
yongtao 16069 0.0 0.8 25524 4560 ? S 11:09 0:00 dcopserver [kdeinit] --n
yongtao 16072 0.0 1.3 26080 6604 ? S 11:09 0:00 klauncher [kdeinit]
yongtao 16074 0.0 1.5 26584 8080 ? S 11:09 0:00 kded [kdeinit]
yongtao 16156 0.0 1.3 32540 6996 ? S 11:09 0:00 knotify [kdeinit]
yongtao 16157 0.0 2.0 33524 10396 ? S 11:09 0:00 knotify [kdeinit]
yongtao 16160 0.4 1.1 11804 5620 ? S 11:09 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16166 0.5 1.1 11804 5624 ? S 11:09 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16171 0.5 1.1 11804 5624 ? S 11:10 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16174 0.5 1.1 11804 5628 ? S 11:10 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16179 0.6 1.1 11804 5624 ? S 11:10 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16186 0.6 1.1 11804 5624 ? S 11:10 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16195 0.7 1.1 11804 5628 ? S 11:10 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16203 0.7 1.1 11804 5628 ? S 11:10 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16212 0.8 1.1 11804 5628 ? S 11:10 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16222 0.9 1.1 11804 5628 ? S 11:10 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16226 0.9 1.1 11936 5828 ? SL 11:10 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16229 1.0 1.1 11936 5828 ? SL 11:10 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16232 1.0 1.1 11936 5828 ? SL 11:10 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16235 1.0 1.1 11936 5824 ? SL 11:11 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16238 1.0 1.1 11936 5824 ? SL 11:11 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16241 1.0 1.1 11936 5828 ? SL 11:11 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16244 1.0 1.1 11936 5828 ? SL 11:11 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16247 1.1 1.1 11936 5828 ? SL 11:11 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16250 1.2 1.1 11936 5828 ? SL 11:11 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16253 1.2 1.1 11936 5828 ? SL 11:11 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16256 1.5 1.1 11936 5828 ? SL 11:11 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
yongtao 16259 2.0 1.1 11936 5820 ? SL 11:11 0:00 /usr/bin/artsd -F 10 -S 4096 -s 60 -m artsmessage -l 3 -f
我发现,在你使用konsole时打开多个标签页时,我们关闭konsole时,这个artsd程序就一直运行,直至占用你的内存完毕,系统崩溃,我使用:killall artsd,将所有的artsd程序全部杀掉,没有用,还是会自动生成,没办法,将所有的含有kdeinit字样的进程全部杀掉,系统终于清净了,artsd不会再自动增加了。。。。
yongtao 16066 0.0 1.0 25556 5160 ? Ss 11:09 0:00 kdeinit Running...
yongtao 16069 0.0 0.8 25524 4560 ? S 11:09 0:00 dcopserver [kdeinit] --n
yongtao 16072 0.0 1.3 26080 6604 ? S 11:09 0:00 klauncher [kdeinit]
yongtao 16074 0.0 1.5 26584 8080 ? S 11:09 0:00 kded [kdeinit]
yongtao 16156 0.0 1.3 32540 6996 ? S 11:09 0:00 knotify [kdeinit]
yongtao 16157 0.0 2.0 33524 10408 ? S 11:09 0:00 knotify [kdeinit]
第二个问题,你会体会到linux的强大
xls文件编辑,完全可以使用openoffice来完成。我们将整个openoffice拷贝到文本文档上,发现多了很多的空格,这是由于tab键造成的,解决办法就是:
yongtao@ubuntu:~/km118/src/appmeter$ tr -d "[\t]"dataitem2.dat
yongtao@ubuntu:~/km118/src/appmeter$ tr -d "[\t]"dataitem2.dat
yongtao@ubuntu:~/km118/src/appmeter$ tr -d "[\t]"dataitem2.dat
使用tr命令删除dataitem.dat中所有的tab,然后结果输出dataitem2.dat文件中。。。我们来学习一下tr的基本用法
1、关于tr
通过使用 tr,您可以非常容易地实现 sed 的许多最基本功能。您可以将 tr 看作为 sed 的(极其)简化的变体:它可以用一个字符来替换另一个字符,或者可以完全除去一些字符。您也可以用它来除去重复字符。这就是所有 tr 所能够做的。

tr用来从标准输入中通过替换或删除操作进行字符转换。tr主要用于删除文件中控制字符或进行字符转换。使用tr时要转换两个字符串:字符串1用于查询,
字符串2用于处理各种转换。tr刚执行时,字符串1中的字符被映射到字符串2中的字符,然后转换操作开始。
带有最常用选项的tr命令格式为:
tr -c -d -s ["string1_to_translate_from"] ["string2_to_translate_to"] result.txt
(2)删除空行
tr -s "[\012]" b.txt
(5)删除指定字符

一个星期的日程表。任务是从其中删除所有数字,只保留日期。日期有大写,也有小写格式。因此需指定两个字符范围[a-z]和[A-Z],命令tr
-cs "[a-z][A-Z]" "[\012*]"
将文件每行所有不包含在[a-z]或[A-Z](所有希腊字母)的字符串放在字符串1中并转换为一新行。-s选项表明压缩所有新行,
-c表明保留所有字母不动。原文件如下,后跟tr命令:
tr -cs "[a-z][A-Z]" "[\012*]" stat.tmp
用新行替换每行末尾的^M,并用\n去除^Z,输入要来自于临时工作文件stat.tmp。
tr -s "[\015][\032]" "\n"
(7)替换passwd文件中所有冒号,代之以tab键,可以增加可读性
tr -s "[:]" "[\011]" UNIX:tr "\r" "\n" unixfile
UNIX -> Mac:tr "\n" "\r" macfile
Microsoft DOS/Windows 约定,文本的每行以回车字符(\r)并后跟换行符(\n)结束。为了纠正这个问题,可以使用下列命令:
DOS -> UNIX:tr -d "\r" unixfile
UNIX -> DOS:在这种情况下,需要用awk,因为tr不能插入两个字符来替换一个字符。要使用的 awk 命令为 awk '{ print $0"\r" }' dosfile
注:都可以用sed 来完成。







最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 11:26 , Processed in 0.114750 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部