[{"data":1,"prerenderedAt":392},["ShallowReactive",2],{"$f10nkhfp9e7huv":3},{"title":4,"date":5,"tags":6,"categories":9,"draft":11,"_id":12,"slug":13,"path":14,"document":15,"excerpt":390,"readingTimeMinutes":391},"Tip: Re-running Bash Commands","2021-09-22T00:00:00.000Z",[7,8],"tip","bash",[10],"tips",false,"content:blog:quick-tip-rerunning-bash-commands","quick-tip-rerunning-bash-commands","\u002Fblog\u002Fquick-tip-rerunning-bash-commands",{"frontmatter":16,"meta":17,"nodes":18},{},{},[19,28,32,88,101,160,163,179,247,261,297,304,325,335,358,372,374],[20,21,22,23,27],"p",{},"Do you ever find yourself having to re-run a Bash command? I often find this\nhappening to myself when I neglect to use ",[24,25,26],"code",{},"sudo"," for a command that requires\nroot privileges.",[29,30,31],null,{},"more",[33,34,36],"pre",{"language":8,"class":35},"shiki shiki-themes tokyo-night dark:tokyo-night",[24,37,39,56,57],{"class":38},"language-bash",[40,41,44,48,52],"span",{"class":42,"style":43},"line","display: inline",[40,45,47],{"style":46},"color:#C0CAF5","$",[40,49,51],{"style":50},"color:#9ECE6A"," pacman",[40,53,55],{"style":54},"color:#E0AF68"," -Syu","\n",[40,58,59,62,65,68,71,74,77,80,82,85],{"class":42,"style":43},[40,60,61],{"style":46},"error:",[40,63,64],{"style":50}," you",[40,66,67],{"style":50}," cannot",[40,69,70],{"style":50}," perform",[40,72,73],{"style":50}," this",[40,75,76],{"style":50}," operation",[40,78,79],{"style":50}," unless",[40,81,64],{"style":50},[40,83,84],{"style":50}," are",[40,86,87],{"style":50}," root.",[20,89,90,91,94,95,97,98,100],{},"Well, I have good news for you -- you can easily re-issue a command with the\n",[24,92,93],{},"!!"," designator! Simply type ",[24,96,26],{}," followed by ",[24,99,93],{}," and you're good to go.",[33,102,103],{"language":8,"class":35},[24,104,105,56,115,56,123,56,145],{"class":38},[40,106,107,109,112],{"class":42,"style":43},[40,108,47],{"style":46},[40,110,111],{"style":50}," sudo",[40,113,114],{"style":50}," !!",[40,116,117,119,121],{"class":42,"style":43},[40,118,26],{"style":46},[40,120,51],{"style":50},[40,122,55],{"style":54},[40,124,125,129,132,135,138,142],{"class":42,"style":43},[40,126,128],{"style":127},"color:#89DDFF","[",[40,130,26],{"style":131},"color:#A9B1D6",[40,133,134],{"style":127},"]",[40,136,137],{"style":131}," password ",[40,139,141],{"style":140},"color:#BB9AF7","for",[40,143,144],{"style":131}," colton:",[40,146,147,151,154,157],{"class":42,"style":43},[40,148,150],{"style":149},"color:#0DB9D7","::",[40,152,153],{"style":50}," Synchronizing",[40,155,156],{"style":50}," package",[40,158,159],{"style":50}," databases...",[20,161,162],{},"--",[20,164,165,166,169,170,174,175,178],{},"Commands that are prefixed with a bang, ",[24,167,168],{},"!",", are considered ",[171,172,173],"em",{},"Event\nDesignators,"," and are references to your command-line history. You can take a\nlook at your history with the ",[24,176,177],{},"history"," command.",[33,180,181],{"language":8,"class":35},[24,182,183,56,190,56,201,56,209,56,226],{"class":38},[40,184,185,187],{"class":42,"style":43},[40,186,47],{"style":46},[40,188,189],{"style":50}," history",[40,191,192,195,198],{"class":42,"style":43},[40,193,194],{"style":46}," 1021",[40,196,197],{"style":50},"  touch",[40,199,200],{"style":50}," hello_world.txt",[40,202,203,206],{"class":42,"style":43},[40,204,205],{"style":46}," 1022",[40,207,208],{"style":50},"  ls",[40,210,211,214,217,220,223],{"class":42,"style":43},[40,212,213],{"style":46}," 1023",[40,215,216],{"style":50},"  echo",[40,218,219],{"style":127}," \"",[40,221,222],{"style":50},"Here we go again!",[40,224,225],{"style":127},"\"",[40,227,228,231,234,237,240,244],{"class":42,"style":43},[40,229,230],{"style":46}," 1024",[40,232,233],{"style":50},"  find",[40,235,236],{"style":50}," .",[40,238,239],{"style":54}," -name",[40,241,243],{"style":242},"color:#F7768E"," *",[40,245,246],{"style":50},".py",[20,248,249,250,252,253,256,257,260],{},"There are many ways to use ",[24,251,168],{}," in your shell. For example, if you wanted to\nre-issue a specific command in your history, you could use ",[24,254,255],{},"!n"," where ",[24,258,259],{},"n"," is\nthe number next to the command in your history.",[33,262,263],{"language":8,"class":35},[24,264,265,56,272,56,283],{"class":38},[40,266,267,269],{"class":42,"style":43},[40,268,47],{"style":46},[40,270,271],{"style":50}," !1023",[40,273,274,277,279,281],{"class":42,"style":43},[40,275,276],{"style":149},"echo",[40,278,219],{"style":127},[40,280,222],{"style":50},[40,282,225],{"style":127},[40,284,285,288,291,294],{"class":42,"style":43},[40,286,287],{"style":46},"Here",[40,289,290],{"style":50}," we",[40,292,293],{"style":50}," go",[40,295,296],{"style":50}," again!",[20,298,299,300,303],{},"Or... if you wanted to run the command you issued 4-commands ago, you can use\n",[24,301,302],{},"!-4",".",[33,305,306],{"language":8,"class":35},[24,307,308,56,315,56,320],{"class":38},[40,309,310,312],{"class":42,"style":43},[40,311,47],{"style":46},[40,313,314],{"style":50}," !-4",[40,316,317],{"class":42,"style":43},[40,318,319],{"style":46},"ls",[40,321,322],{"class":42,"style":43},[40,323,324],{"style":46},"hello_world.txt",[20,326,327,328,331,332,303],{},"Or... if you wanted to run the last command that started with the string\n",[171,329,330],{},"find",", you can use ",[24,333,334],{},"!find",[33,336,337],{"language":8,"class":35},[24,338,339,56,346],{"class":38},[40,340,341,343],{"class":42,"style":43},[40,342,47],{"style":46},[40,344,345],{"style":50}," !find",[40,347,348,350,352,354,356],{"class":42,"style":43},[40,349,330],{"style":46},[40,351,236],{"style":50},[40,353,239],{"style":54},[40,355,243],{"style":242},[40,357,246],{"style":50},[20,359,360,361,364,365,367,368,371],{},"Be sure to check out the ",[171,362,363],{},"Event Designators"," section of the ",[24,366,8],{}," ",[24,369,370],{},"man"," pages\nfor more information!",[20,373,162],{},[20,375,376,377,382,383,386,387,389],{},"As an aside, for even faster command-line history navigation, be sure to check\nout the excellent ",[378,379,381],"a",{"href":380},"https:\u002F\u002Fgithub.com\u002Fjunegunn\u002Ffzf","fzf"," utility by ",[171,384,385],{},"junegunn.","\nOne of the many features of ",[24,388,381],{}," is browsing and re-issuing commands from your\ncommand-line history with a fuzzy-finder!","Do you ever find yourself having to rerun a Bash command? I often find this happening to myself when I neglect to use sudo for a command that requires root privileges.",1,1790648870532]