LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 998|回复: 2

求助:请问如何删除文本里面的以回车符开始的空行?

[复制链接]
发表于 2010-4-8 10:15:32 | 显示全部楼层 |阅读模式
如附件所示,本来只有16行非空行,但是由于进行了删除操作后,多出了3行以回车符开始的空行,当然可以手工删除,但是是否有相应的shell命令来自动删除后面多余的3个空行呢(注意这3个空行是由回车造成的)。谢谢

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
发表于 2010-4-8 11:14:24 | 显示全部楼层
sed '/^$/d'

grep \n order.txt



  1. imghchco [ ~ ]0$ cat order.txt
  2. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/29cc990e-7fb0-4667-987d-140284184157.rar
  3. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/b6b49001-6250-40dc-bc7f-ba4117856075.rar
  4. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/e4555ae5-031c-4828-ace6-038c41958c36.rar
  5. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/48fa0fa7-6dc2-45ea-9771-28b3cf1e65cd.rar
  6. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/f366f760-0bf7-4dbb-b27d-5354752448a7.rar
  7. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/2d07bda5-d553-4d04-b38a-7cc7ba03b7ce.rar
  8. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/8c7fc132-e328-4860-ab7b-582f853c6776.rar
  9. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/bec9e2dc-68f5-4b31-a3b9-fb1d84d02a85.rar
  10. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/fcfae636-7c0b-405c-953b-f27ca0f09ae4.rar
  11. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/8c091a14-ebb3-4e73-9feb-1399e8d6a187.rar
  12. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/e8654e25-d29b-4c6a-af08-23c839006029.rar
  13. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/bf510915-064e-4454-8c80-37a83f790c43.rar
  14. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/49189031-ccd7-4c9f-9b42-03c4f0953c26.rar
  15. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/cf7d8396-bb81-42ab-9b5f-21b76b0641fb.rar
  16. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/8d20c4e1-3804-41e1-acf5-126cdaf54c86.rar
  17. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/40b4cf20-601a-4fd4-b51b-55c3af83d4d3.rar



  18. imghchco [ ~ ]0$ grep \n order.txt
  19. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/29cc990e-7fb0-4667-987d-140284184157.rar
  20. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/b6b49001-6250-40dc-bc7f-ba4117856075.rar
  21. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/e4555ae5-031c-4828-ace6-038c41958c36.rar
  22. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/48fa0fa7-6dc2-45ea-9771-28b3cf1e65cd.rar
  23. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/f366f760-0bf7-4dbb-b27d-5354752448a7.rar
  24. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/2d07bda5-d553-4d04-b38a-7cc7ba03b7ce.rar
  25. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/8c7fc132-e328-4860-ab7b-582f853c6776.rar
  26. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/bec9e2dc-68f5-4b31-a3b9-fb1d84d02a85.rar
  27. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/fcfae636-7c0b-405c-953b-f27ca0f09ae4.rar
  28. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/8c091a14-ebb3-4e73-9feb-1399e8d6a187.rar
  29. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/e8654e25-d29b-4c6a-af08-23c839006029.rar
  30. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/bf510915-064e-4454-8c80-37a83f790c43.rar
  31. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/49189031-ccd7-4c9f-9b42-03c4f0953c26.rar
  32. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/cf7d8396-bb81-42ab-9b5f-21b76b0641fb.rar
  33. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/8d20c4e1-3804-41e1-acf5-126cdaf54c86.rar
  34. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/40b4cf20-601a-4fd4-b51b-55c3af83d4d3.rar
  35. imghchco [ ~ ]0$
复制代码



  1. imghchco [ ~ ]0$ cat order.txt | sed '/^$/d'
  2. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/29cc990e-7fb0-4667-987d-140284184157.rar
  3. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/b6b49001-6250-40dc-bc7f-ba4117856075.rar
  4. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/e4555ae5-031c-4828-ace6-038c41958c36.rar
  5. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/48fa0fa7-6dc2-45ea-9771-28b3cf1e65cd.rar
  6. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/f366f760-0bf7-4dbb-b27d-5354752448a7.rar
  7. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/2d07bda5-d553-4d04-b38a-7cc7ba03b7ce.rar
  8. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/8c7fc132-e328-4860-ab7b-582f853c6776.rar
  9. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/bec9e2dc-68f5-4b31-a3b9-fb1d84d02a85.rar
  10. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/fcfae636-7c0b-405c-953b-f27ca0f09ae4.rar
  11. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/8c091a14-ebb3-4e73-9feb-1399e8d6a187.rar
  12. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/e8654e25-d29b-4c6a-af08-23c839006029.rar
  13. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/bf510915-064e-4454-8c80-37a83f790c43.rar
  14. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/49189031-ccd7-4c9f-9b42-03c4f0953c26.rar
  15. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/cf7d8396-bb81-42ab-9b5f-21b76b0641fb.rar
  16. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/8d20c4e1-3804-41e1-acf5-126cdaf54c86.rar
  17. http://bbsrrs1.joy.cn/56B0C540017CAAF69DC88E6AD105D392/BBS/up_file/2010-03-03/40b4cf20-601a-4fd4-b51b-55c3af83d4d3.rar
  18. imghchco [ ~ ]0$
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-4-8 15:12:08 | 显示全部楼层
谢谢ServerOnly提供的方法,我已经解决了!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表