Watching a video (https://vimeo.com/56166857 & https://www.youtube.com/watch?v=9CTfGS0gEOk @ 1m:34s), the presenter (TJ Holowaychuk) wrote:

touch !!:2{...}

I can't find what !!:2 means anywhere.

I get the (repeat the previous command) !! but, the meaning of


I don't know, can't find an answer for and the search here returned no results for, so ... I'm stuck.


to create several directories at once, he wrote:

mkdir -p lib/{login,signup,users,posts}

to create the same files in each of those directories, he wrote:

touch !!:2/{package.json,index.json}

The output was:

touch lib/{login,signup,users,posts}/{package.json,index.json}

The result was:

The two files were created in each of the directories.

  • @StephenRauch yes, except that the !!:/anything as described by the OP is invalid syntax and returns -bash: /: unrecognized history modifier. – roaima Mar 12 '17 at 23:55

You've misread what the presenter entered. This is what is actually given on the video:

mkdir -p lib/{login,signup,users,posts}
touch !!:2/{package.json,index.json}

This extends the !! instruction to repeat the previous command, but the :2 modifier says use the second argument. So, here !!:2 is the lib/{login,signup,users,posts} component.

|improve this answer|||||
  • sorry, left out the "2" it was a part of my wtf is that confusion. adding it now. so ... the colon then is an argument separator ... like, do 1, do 2 like the bash semicolon? – iletras Mar 12 '17 at 23:57
  • 2
    @iletras in the manual, "!! Refer to the previous command. This is a synonym for !-1." and "Word designators are used to select desired words from the event. A : separates the event specification from the word designator. [...] Words are numbered from the beginning of the line, with the first word being denoted by 0 (zero)." – roaima Mar 12 '17 at 23:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.