Showing posts with label remove all .svn directories. Show all posts
Showing posts with label remove all .svn directories. Show all posts

Một số lệnh thông dụng trong linux

1. Xóa toàn bộ các file .svn
  find . -name .svn -print0 | xargs -0 rm -rf
2. Xử lý với các file và thư mục trong thư mục hiện hành.
Ví dụ: chmod riêng folder hoặc file

find . -type d -print0 |xargs -0 chmod 755
find . -type f -print0 |xargs -0 chmod 644
hoặc
find . -type d | xargs chmod 644

3. Forward port thông qua ssh
sudo ssh -L 3308:IPserver:3306   user@IPserver

4. Grep: get 10 lines After ,  get 10 lines Before
cat file.txt | grep -A10 "test" | wc -l
cat file.txt | grep -B10 "test" | wc -l

Còn nữa..

How to remove all .svn directories from my application directories



xargs takes input, usually separated by newlines, and places them on the command line, so adding xargs makes what you had work:

find . -name .svn | xargs rm -fr

xargs is intelligent enough that it will only pass as many arguments to rm as it can accept. Thus, if you had a million files, it might run rm 1,000,000/65,000 times (if your shell could accept 65,002 arguments on the command line {65k files + 1 for rm + 1 for -fr}).

As persons have adeptly pointed out, the following also work:
find . -name .svn -exec rm -rf {} \; 
find . -depth -name .svn -exec rm -fr {} \; 
find . -type d -name .svn -print0|xargs -0 rm -rf 

The first two -exec forms both call rm for each folder being deleted, so if you had 1,000,000 folders, rm would be invoked 1,000,000 times. This is certainly less than ideal. Newer implementations of rm allow you to conclude the command with a + indicating that rm will accept as many arguments as possible:
find . -name .svn -exec rm -rf {} +