Skip to content

Instantly share code, notes, and snippets.

@delphym
Last active December 14, 2018 00:39
Show Gist options
  • Save delphym/0d6ec4736ad129019d6fd57a6946fb05 to your computer and use it in GitHub Desktop.
Save delphym/0d6ec4736ad129019d6fd57a6946fb05 to your computer and use it in GitHub Desktop.
MISC
### Howto capture regexp group and print it
ll -1
em110msp_1.0.13-10_release-unsigned.apk
em110msp_1.0.13-10_release-unsigned.json
# daniel@mcs-Ubuntu:
ls -1 | pcregrep -o2 "(.*)_(.*)_(.*)(.apk|.pom|.json)$"
1.0.13-10
1.0.13-10
### -o, --only-matching=n show only the part (#group) of the line that matched
### To list all users in 'sudo' and 'adm' group for usr in `sudo cat /etc/passwd | awk -F':' '{print $1}'`; do id $usr; done | grep sudo | grep -e "(adm)"
for usr in `sudo cat /etc/passwd | awk -F':' '{print $1}'`; do id $usr; done | grep sudo | grep -e "(adm)"
### To remove a user from sudo group
sudo deluser $usr sudo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment