Linux: Ejecutar un comando con el argumento del comando anterior

Has ejecutado un comando en linux (bash) y quieres ejecutar otro comando usando el "argumento" del comando anterior, acá te dejo algunos trucos.

La mejor respuesta tomada desde este link.

Most likely you'd want to go in the recently created directory. You can do this using next "shortcuts":

  • cd Esc. - type cd and after press Esc followed by . (not in the same time). If the previous command has no arguments, you will get the previous command itself.
  • cd !* - in this case you will get all arguments from the previuos command. If the previous command has no arguments, you will get nothing.
  • cd !$ - in this case you will get the last arguments from the previuos command. If the previous command has no arguments, you will get nothing.
  • cd Alt+. - type cd and after press Alt and . (in the same time). In fact, using this way and continuing to press . (without to release Alt), you will get the last argument for every command from history. If a command has no arguments, you will get the command itself.

In general:  <command> Esc+.  or  <command> !*  or  <command> !$  or  <command> Alt+..

Otros comandos Terminal / Bash / Linux / Unix

El siguiente los llevará a mi github donde he publicado una lista de comandos con una breve explicación LINK

2 comments on “Linux: Ejecutar un comando con el argumento del comando anterior

  1. Heya i'm for the first time here. I came across this board and I find It truly useful & it helped me out much.
    I hope to give something back and aid others like you
    helped me.

  2. whoah this weblog is excellent i love studying your posts.

    Stay up the great work! You recognize, many persons are searching
    around for this info, you can help them greatly.

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.