Morph9@lemmy.zip to linuxmemes@lemmy.worldEnglish · 2 days agoSudo disbelieflemmy.zipexternal-linkmessage-square102fedilinkarrow-up1365arrow-down110
arrow-up1355arrow-down1external-linkSudo disbelieflemmy.zipMorph9@lemmy.zip to linuxmemes@lemmy.worldEnglish · 2 days agomessage-square102fedilink
minus-squareDasFaultier@sh.itjust.workslinkfedilinkEnglisharrow-up16·edit-22 days agoIt is indeed. For those unaware: sudo !! if your previous command failed because you forgot sudo.
minus-squarePotatoesFall@discuss.tchncs.delinkfedilinkarrow-up8·2 days agoLet’s say I run something like rm a.txt && rm b.txt, will sudo !! work for both commands or just the first?
minus-squareSkullgrid@lemmy.worldlinkfedilinkarrow-up7·edit-22 days ago!! basically pastes the last … action you took as an interaction with the shell. it’s the same as pressing the up arrow, and putting whatever you want in the same position relative to the !! https://youtu.be/PRm6tYo8nGY?t=64
minus-squareDasFaultier@sh.itjust.workslinkfedilinkEnglisharrow-up4·2 days agoRelevant bash manpage section here.
minus-squarePoolloverNathan@programming.devlinkfedilinkEnglisharrow-up3·2 days ago!! is pure textual substitution, so it’d be sudo rm a.txt && rm b.txt. You could do something like sudo sh -c "!!" though.
minus-squareDasFaultier@sh.itjust.workslinkfedilinkEnglisharrow-up4·2 days agoI wasn’t sure, so I tested this. Turns out, only a.txt would be deleted and removal of b.txt fails due to lack of permissions.
It is indeed.
For those unaware:
sudo !!if your previous command failed because you forgotsudo.Let’s say I run something like
rm a.txt && rm b.txt, willsudo !!work for both commands or just the first?!! basically pastes the last … action you took as an interaction with the shell. it’s the same as pressing the up arrow, and putting whatever you want in the same position relative to the !!
https://youtu.be/PRm6tYo8nGY?t=64
Relevant bash manpage section here.
!!is pure textual substitution, so it’d besudo rm a.txt && rm b.txt. You could do something likesudo sh -c "!!"though.I wasn’t sure, so I tested this. Turns out, only
a.txtwould be deleted and removal ofb.txtfails due to lack of permissions.Both
TIL thank you!