bash单词合并

If your workflow is populated with a lot of repetitive actions, then it never hurts to look for ways to improve and streamline your workflow. Today’s SuperUser Q&A post has some helpful suggestions for a reader seeking to improve his workflow.

如果您的工作流程中包含许多重复性操作,那么寻找改进和简化工作流程的方法就不会有什么坏处。 今天的“超级用户问答”帖子为寻求改善工作流程的读者提供了一些有用的建议。

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。

Screenshot courtesy of Matt Joyce (Flickr).

屏幕截图由Matt Joyce(Flickr)提供。

问题 (The Question)

SuperUser reader coin wants to know how to quickly change the first word in a bash command:

超级用户阅读器硬币想知道如何快速更改bash命令中的第一个单词:

I would like to improve my workflow in bash and realized that I often want to execute the same command to a different executable.

我想改善bash的工作流程,并意识到我经常想对不同的可执行文件执行同一命令。

Some Examples

一些例子

1.) Git

1.)Git

2.) Bash

2.)重击

I know that I can hit Ctrl+a then Del to remove the first word, but I am wondering if there is a quicker way to do it.

我知道我可以先按Ctrl + a再按Del来删除第一个单词,但是我想知道是否有更快的方法。

Is there a quicker way for coin to change the first word in bash commands?

硬币有更快的方法来更改bash命令中的第一个单词吗?

答案 (The Answer)

SuperUser contributors Spiff, Hastur, jjlin. and Gustavo Giraldez have the answer for us. First up, Spiff:

超级用户贡献者Spiff,Hastur和jjlin。 Gustavo Giraldez为我们提供了答案。 首先,Spiff:

!$ expands to the last word of your previous command. So you could do:

!$扩展到上一个命令的最后一个单词。 因此,您可以执行以下操作:

Or

要么

Your examples happened to only repeat the last word, so !$ worked fine. If you actually had a lot of arguments that you wanted to repeat, and you just wanted to change the first word, you could use !*, which expands to all words of the previous command except the zeroth.

您的示例碰巧只重复了最后一个字,所以!$可以正常工作。 如果您实际上有很多要重复的参数,并且只想更改第一个单词,则可以使用!*,它扩展为除零以外的上一个命令的所有单词。

See the “HISTORY EXPANSION” section of the bash man page. There is a lot of flexibility there.

请参见bash手册页的“ HISTORY EXPANSION”(历史扩展)部分。 那里有很多灵活性。

Followed by the answer from Hastur:

接下来是Hastur的答案:

I would like to add a warning (see the answer from Spiff above). With !$, you do not have full visual control of the line you are running. The results can be harmful sometimes, especially if you incur a misprint. It takes what it needs from the history to expand on.

我想添加一个警告(请参见上面Spiff的回答)。 使用!$,您将无法完全直观地控制正在运行的行。 有时结果可能是有害的,尤其是在打印错误的情况下。 它需要从历史中获得所需的扩展。

So if you write the last command with a blank space at the beginning, then this command will probably not finish from the history. When you execute your new command with !$, the shell will not take the parameters from the last command line typed, but only from the last part of the history.

因此,如果您在末尾写上最后一个命令,则该命令可能不会从历史记录中结束。 当用!$执行新命令时,shell将不会从键入的最后一个命令行中获取参数,而只会从历史记录的最后一部分中获取参数。

Here are some more helpful words and commands.

这是一些更有用的单词和命令。

Then the answer from jjlin:

然后jjlin的答案:

Ctrl+a to go to the beginning of the line, then Alt+d to delete the first word.

Ctrl + a转到行的开头,然后按Alt + d删除第一个单词。

And our final answer from Gustavo Giraldez:

我们对古斯塔沃·吉拉尔德斯(Gustavo Giraldez)的最终回答是:

The delete word shortcut is actually Meta+d, and Meta is usually mapped to Alt on Linux machines. On platforms where this is not the case, an alternative to get the Meta modifier is to use Esc as a prefix. You can read more about the Meta Key here.

删除单词快捷方式实际上是Meta + d ,并且Meta通常在Linux计算机上映射到Alt 。 在不是这种情况的平台上,获取Meta修饰符的另一种方法是使用Esc作为前缀。 您可以在此处阅读有关元密钥的更多信息。



Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

有什么补充说明吗? 在评论中听起来不错。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程。

翻译自: https://www.howtogeek.com/207955/how-to-quickly-change-the-first-word-in-a-bash-command/

bash单词合并

bash单词合并_如何在Bash命令中快速更改第一个单词?相关推荐

  1. centos7 vim查找_如何在 Vim/Vi 中快速查找和替换文本内容

    Vim 是 Vi 多模式命令行编辑器的加强版,通常默认的Unix或Linux系统中都默认自带Vi命令编辑器.当然,为了更好的体验,如果系统默认没有安装Vim,建议安装Vim. 通过本文的讲解,你将学会 ...

  2. centos sftp客户端 c 源码_如何在 Linux 系统中如何更改 SFTP 端口

    如何在 Linux 系统中如何更改 SFTP 端口 SFTP(SSH文件传输协议)是一种安全文件协议,用于通过加密连接在两个主机之间传输文件.它还允许您对远程文件执行各种文件操作并恢复文件传输. SF ...

  3. bash 脚本编写_如何在Bash中编写循环

    bash 脚本编写 人们想要学习Unix shell的一个常见原因是释放批处理的功能. 如果要对多个文件执行某些操作,一种方法是构造一个遍历这些文件的命令. 在编程术语中,这称为执行控制,最常见的示例 ...

  4. 怎样在dos窗口中启动mysql服务器_如何在dos命令中启动mysql或sql server 服务器的一些操作...

    ========================dos命令启动mysql或者sql srever 的步骤================= 一.dos命令启动mysql 1.进入dos命令窗口 2.启 ...

  5. python怎么设置画布颜色_如何在kivy python中动态更改画布颜色?

    解决方案 提供颜色的模式(rgb,rgba).将颜色(铅笔色)替换为颜色(rgba=pencolor) 详情请参考下面的演示.笔的颜色从红色开始变为白色,即按钮的背景色.在 示例 在主.py在from ...

  6. jieba使用自定义词典_如何在Word 2013中使用自定义词典

    jieba使用自定义词典 If you have the option on for checking spelling as you type in Word 2013, you can easil ...

  7. linux下开放sftp端口,如何在 Linux 系统中如何更改 SFTP 端口

    如何在 Linux 系统中如何更改 SFTP 端口 SFTP(SSH文件传输协议)是一种安全文件协议,用于通过加密连接在两个主机之间传输文件. 它还允许您对远程文件执行各种文件操作并恢复文件传输. S ...

  8. ftp改为sftp_如何在 Linux 系统中如何更改 SFTP 端口

    如何在 Linux 系统中如何更改 SFTP 端口 SFTP(SSH文件传输协议)是一种安全文件协议,用于通过加密连接在两个主机之间传输文件.它还允许您对远程文件执行各种文件操作并恢复文件传输. SF ...

  9. 如何在 IntelliJ IDEA 中快速生成 JavaDoc 注释模板

    如何在 IntelliJ IDEA 中快速生成 JavaDoc 注释模板 此博客存在上一个版本,如果读者对笔者以前版本的博客依然感兴趣,可以访问此链接:https://blog.csdn.net/wa ...

最新文章

  1. 从github上下载项目到eclipse
  2. 华为云免费体验 怎么使用_华为云Classroom免费向全国高校开放,云端学习更高效...
  3. OpenGL 位移贴图实例
  4. P6775-[NOI2020]制作菜品【贪心,dp】
  5. Linux 编辑doc,Linux命令大全(文档编辑).doc
  6. 解决 vmware 死锁 :take ownership failed
  7. python官网下载安装-Python2.7.6下载
  8. maven 生命周期的指令
  9. 【交通标志识别】基于matlab GUI SIFT交通标志识别【含Matlab源码 864期】
  10. 使用JSP 编写九九乘法表
  11. 第三届中青杯B题思路
  12. 3dmax渲染很慢/很卡?
  13. 【高通量测序】.dna文件批量读取CAG重复序列长度
  14. 一种使用内存做硬盘的方法,提升读写速度
  15. 区块链白皮书阅读笔记
  16. 端口映射工具rinetd
  17. Git从入门到熟练第八讲 创建和使用分支
  18. 手机接入点 CMWAP 和CMNET
  19. 编码规范与数学之美感想
  20. 客户端计算机自动安装officescan

热门文章

  1. TIM_CCxChannelCmd函数无法关闭互补通道输出
  2. 51vsr.com index.php,vishay
  3. 检验杜宾 瓦森检验法R语言_期货投资分析模拟试题及答案解析(6)
  4. 【研究生工作周报第十四周】
  5. 华为电脑linux怎么连接鼠标,华为无线鼠标怎么连接电脑 华为无线鼠标如何连接电脑...
  6. react路由鉴权 / 路由守卫(常用经实践可行 推荐阅读)
  7. xposed框架android9.0,安卓框架虚拟机VirtualXposed v0.17.1 清爽版 支持安卓9.0系统
  8. QT QSS设置炫彩字体
  9. 分享 | 如何在不同工艺间进行设计的移植转换
  10. SMIC 14 STDCELL库的构成总结