Morph9@lemmy.zip to linuxmemes@lemmy.worldEnglish · 2 months agoSudo disbelieflemmy.zipexternal-linkmessage-square86fedilinkarrow-up1356arrow-down112
arrow-up1344arrow-down1external-linkSudo disbelieflemmy.zipMorph9@lemmy.zip to linuxmemes@lemmy.worldEnglish · 2 months agomessage-square86fedilink
minus-squarePotatoesFall@discuss.tchncs.delinkfedilinkarrow-up6·2 months agoLet’s say I run something like rm a.txt && rm b.txt, will sudo !! work for both commands or just the first?
minus-squareDasFaultier@sh.itjust.workslinkfedilinkEnglisharrow-up4·2 months 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.
minus-squarePoolloverNathan@programming.devlinkfedilinkEnglisharrow-up3·2 months 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-22 months 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 months agoRelevant bash manpage section here.
Let’s say I run something like
rm a.txt && rm b.txt, willsudo !!work for both commands or just the first?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
!!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.