This is mostly just a post for my recollection. To search all files and subdirectories recursively for a phrase:
grep -r -i somethingtosearchfor ./
Delete files older than 7 days
find . -type f -mtime +7 -exec rm -rf {} \;
find . -daystart -maxdepth 1 -type f -mtime +7 -exec echo rm {} \; (echo before submitting, and doesn't remove files in sub directories).
Delete files following a certain pattern
find -name "3j*" -exec rm -rf {} \;
for linux if u want to return to previous directory u can type.
eg:
$ cd -
Count Files in current directory:
ls -l | awk '!/^d/{print }' | wc -l
Find specific files and replace string:
find -type f -name pom.xml|xargs sed -i 's/4.5.1/4.6.0/g'
grep --include 'pom.xml' -rn 4.5.1 .
grep --include 'pom.xml' -rn 4.6.0
.
sha256sum
sha256sum ubuntu-9.10-dvd-i386.iso
Find IP Mac:
ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}'
Create user and add to sudo group:
42 sudo adduser
43 sudo adduser solis-user
44 sudo usermod
45 sudo usermod -aG sudo solis-user
No comments:
Post a Comment