linux命令题目(2)

65 阅读4分钟

VIM操作

将以下文字复制到vim中并起名为exam.txt:

现在,以互联网为代表的信息技术迅速发展, Internet nowadays, which spearheads information technology, is developing at a breathtaking pace. 引领了生产新变革,创造了人类生活新空间,拓展了国家治理新领域。 It revolutionizes new production processes, creates new spaces in people’s lives, and expands new territories in countries’ domains. 中国大力实施网络强国战略、国家信息化战略、国家大数据战略、"互联网+"行动计划。 Strategically, China is striving to have formidable presence, nationwide informalization, national big data, and internet action plan in the cyber space. 中国大力发展电子商务,推动互联网和实体经济深度融合发展,改善资源配置。 Concurrently it is developing e-commerce, promoting virtual and brick-and-mortar business integration, and improving resource allocation. 这些措施为推动创新发展、转变经济增长方式、调整经济结构发挥积极作用。 These measures intend to drive the development of innovation, alter the fashion of economic growth, and modify economic structures for constructive effectiveness. ---------------------------------------------- 中国欢迎公平、开放、竞争的市场, China embraces a market with a level field, freedom of access and competitiveness. 在自身发展的同时,致力于推动全球数字经济发展。 It endeavors to advance growth not only for itself, but for that of the digital economy worldwide. 中国主张自由贸易,反对贸易壁垒和贸易保护主义。 It has always been China’s position to support free trade and oppose trade barriers and protectionism. 我们希望建立开放、安全的数字经济环境,确保互联网为经济发展和创新服务。 Hopefully we can build an environment for a liberalized and safe digital economy in the web that assures its continuing development and innovation. 我们主张互联网接入应公平、普遍。 We maintain the worldwide-web should be unbiased and widely available. 中国愿加强同其他国家和地区在网络安全和信息技术方面的交流与合作。 China is willing to strengthen exchanges and collaboration with other countries/territories in the safety and technology of internet. 我们应共同推进互联网技术的发展和创新, We should all work together in advancing the development and innovation of internet technology. 确保所有人都能平等分享数字红利,实现网络空间的可持续发展。 As well, we should ensure every participant will reap a fair share of the digital bonuses in order that the development in cyber space will continuee 劝君莫惜金缕衣, Be heeded to indulge not in golden wears; 劝君惜取少年时。 Be cautioned to cherish well youthful years. 花开堪折直须折, Pick nice Flowers timely while in bloom. 莫待无花空折枝。 Pick not flowerless branches as in doom.


1. 加上行号显示

  • 编辑and创建文件 在这里插入图片描述


  • a后粘贴在这里插入图片描述


  • ESC,输入:set nu 在这里插入图片描述

2. 跳到最后一行,在最后一行的下面添加一句话: 诗歌的题目是: 金缕衣

  • Gctrl+g到最后一行 在这里插入图片描述

  • o跳到下一行 在这里插入图片描述

  • a后粘贴内容 在这里插入图片描述

3. 复制第2题的整行,粘贴到 Be heeded to indulge not in golden wears的上一行

  • 命令行模式,在最后一行,按两下yyy,复制整行

  • 输入/Be heed搜素目标行,回车定位 在这里插入图片描述 在这里插入图片描述

  • 光标往上一行,按p粘贴 在这里插入图片描述

4. 在第20行向右移动15个字符,写出命令

  • 非:命令行输入20gg,定位到第20行 在这里插入图片描述


  • 输入15l,向右移动15个字符 在这里插入图片描述


5. 把金缕衣的诗词加上#注释

  • 命令行输入/金缕衣,确认下位置 在这里插入图片描述

  • 按下ctrl+v进入列编辑模式,选中28-37行 在这里插入图片描述

  • I(大写i),输入#,再按两下ESC 在这里插入图片描述

  • 按下ctrl+v进入列编辑模式,选中30-36行 在这里插入图片描述

  • x删除#号 在这里插入图片描述 这样就把全部金缕衣的诗词加上#注释了

6. 将全文中China 换成 chinese

  • 命令行模式下,输入:0,$s/China/chinese/g(从第0行到最后一行中所有China换成chinese) 在这里插入图片描述 在这里插入图片描述

7. 在vim中不离开vim执行 ls/etc/hosts

  • 命令行模式下,输入:! ls /etc/hosts 在这里插入图片描述

8. 把 cat /etc/hosts的内容添加到文章开头

  • 把光标移到开头,按gg 在这里插入图片描述

  • 输入:r /etc/hosts 在这里插入图片描述

9. 删除第六和第七行

  • 6gg定位到第六行 在这里插入图片描述

  • 按两下d,即dd删除第六行,第七行同理 在这里插入图片描述

10. 去掉行首和行尾

  • 以第一句为例,gg到第一行,按7l的位置 在这里插入图片描述

  • 按下d0前面的字全部删除了 在这里插入图片描述

  • 按下8l的位置 在这里插入图片描述

  • 按下d$,包括以及后面的字全部删除了 在这里插入图片描述

11. 不区分大小写将flower改为fresh

  • 设置不区分大小写,输入:set ic,输入/flower查找有两个符合 在这里插入图片描述

  • 输入:34,36s/flower/fresh,替换34-36行中两处 在这里插入图片描述

12. 将ifconfig的所有内容,添加到第16行的行尾

  • 按下16gg,再按$到16行行尾 在这里插入图片描述

  • 命令输入:! ifconfig,查看输出内容 在这里插入图片描述

  • 复制后按a,再粘贴至行尾 在这里插入图片描述