Morph9@lemmy.zip to linuxmemes@lemmy.worldEnglish · 1 day agoSudo disbelieflemmy.zipexternal-linkmessage-square102linkfedilinkarrow-up1363arrow-down110
arrow-up1353arrow-down1external-linkSudo disbelieflemmy.zipMorph9@lemmy.zip to linuxmemes@lemmy.worldEnglish · 1 day agomessage-square102linkfedilink
minus-squareFlax@feddit.uklinkfedilinkEnglisharrow-up6arrow-down1·1 day agoIt’s a nice precautionary measure
minus-squareDasFaultier@sh.itjust.workslinkfedilinkEnglisharrow-up17·edit-21 day agoIt is indeed. For those unaware: sudo !! if your previous command failed because you forgot sudo.
minus-squarePotatoesFall@discuss.tchncs.delinkfedilinkarrow-up8·1 day agoLet’s say I run something like rm a.txt && rm b.txt, will sudo !! work for both commands or just the first?
minus-squarePoolloverNathan@programming.devlinkfedilinkEnglisharrow-up3·1 day 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-squareSkullgrid@lemmy.worldlinkfedilinkarrow-up7·edit-21 day 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·1 day agoRelevant bash manpage section here.
minus-squareDasFaultier@sh.itjust.workslinkfedilinkEnglisharrow-up4·1 day 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’s a nice precautionary measure
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?!!is pure textual substitution, so it’d besudo rm a.txt && rm b.txt. You could do something likesudo sh -c "!!"though.!! 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.
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!