4126 links
739 private links
  • Doo's links
  • Home
  • Login
  • RSS Feed
  • ATOM Feed
  • Tag cloud
  • Picture wall
  • Daily
  • ► Jouer les vidéos
Links per page: 20 50 100
  • Bash History: Correct / Repeat The Last Command With a Substitution

    Je mets ça là parce que je m'en rappelle jamais :

    This guide explains how to repeat the last command with a substitution under bash shell for command line arguments under Unix like operating systems.

    Bash History: Correct / Repeat The Last Command With a Substitution
    by Vivek Gite on August 12, 2012 last updated February 23, 2016
    in BASH Shell, Linux, UNIX
    
    I often type the wrong command as follows under Linux bash shell:
    
    rsync -av dir1 user@server1.cyberciti.biz:/path/to/dir1
    
    OR
    
    cp -av file1*.txt file2*.txt /path/to/dest
    
    I need to correct those command as follows:
    
    rsync -av dir5 user@server1.cyberciti.biz:/path/to/dir1
    cp -av delta1*.txt delta2*.txt /path/to/dest
    
    How do I replace dir1 with dir5 or file with delta and repeat the last command under bash shell?
    
    The bash shell supports both history search and replace operations. The bash (and many other modern) shell provides access to the command history, the list of commands previously typed. The bash shell supports a history expansion feature found in other shell such as csh.
    Syntax: Bash history search and replace the command args
    
    The syntax is as follows for quick substitution and repeat the last command, replacing word1 with word2:
    
    ^WORD1^WORD2^
    
    OR
    
    !!:s/WORD1/WORD2
    
    OR
    
    !!:gs/WORD1/WORD2
    
    In this example, I’m trying to copy a file called youtube-demo-andriod-app-part1.avi to /backup directory
    $ cp youtube-demo-andriod-app-part-102.avi /backup/
    
    To repeat the last command with a substitution:
    $ ^102^1002^
    
    OR
    $ !!:s/102/1002
    February 23, 2016 12:07:24 PM GMT+01:00 * - permalink -
    QRCode
    - http://www.cyberciti.biz/faq/bash-history-repeat-substitution-command-syntax/
    bash
Links per page: 20 50 100
Shaarli - The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community - Help/documentation