Things work ROMS of Shell script --find command combat (Preliminaries)

First, the operation and maintenance of commonly used commands:
clear the screen: clear
continuous carriage return - to see more clearly the command
mkdir abc: Create a folder abc
Touch abc: Create a file abc
chmod 755 abc: change the permissions, enabling administrators to abc read, write, execute permission; and a group of users and other users only read and execute permissions.
chmod -x abc: abc cancel execute permissions for the owner.
chmod a + x abc: increased execute permissions for everyone.

pwd: View the current directory

u user indicates the owner of the file
g group represented by belonging to the same group (group) with the owner of the file, a user group
o other groups represent other users
a all is represented by key three

Add the permission: +
revoke privileges: -

r read represent can be read, for a directory, if not r permission to view this directory so it means you can not pass ls.
w write representation can be written, for a directory, if not w permission, then it means you can not create new files in the directory.
x excute for executable, for a directory, if there is no x permission, then it means that this can not cd into the directory.

. cd into the current directory
cd into the root directory..
cd ./ enter the parent directory of the parent directory...
LN -s soft link
ll / etc / httpd.conf: lists all file permissions, where the group
; connection two command
&& logical aND (first executed the previous command was successfully execute subsequent commands)
||: logical oR (in front of the fall, to perform later)

Find based on file attributes:
find [directory] -name
example:. Find -name "nginx *" -> file lists all file name contains the nginx
find [directory] -type (after adding f / d, f file, d directory )
Find [directory] -size
Find. -size + 30M (the lookup files larger than 30M)
Find. -size 30M (lookup file is less than 30M)
Find [directory] -perm (followed by the 755/644, etc.)
Find [Contents ] -exec : find the file after execution
find [directory] - [parameters] -exec [command] {} \;
find [directory] -ok : When you find the file asking them not to perform

Packing:
Find -name "* Nginx" -maxdepth. 1 the tar czxf nnnn.tar.gz -exec {};.
Find -type F. -Exec the tar C ZVF n.tar.gz} + {(C = Create)
Find. F -type -exec the tar U VF n.tar.gz {} \; (U = Update)
the tar-1.14.2.tar.gz CZF n1.tar.gz Nginx (packetized file name)

View archive content:
tar TVF n1.tar.gz

-exec and xargs differentiated:
Find -type F | xargs czvf n.tar.gz the tar.
xargs: left output pipe, as supply line command on the right, and a segmentation function performed

tar czvf nnn1.tar.gz nnn.tar.gz --remove-files (delete the original file nnn, generate a new file nnn1)

Released four original articles · won praise 3 · views 88

Guess you like

Origin blog.csdn.net/qq_41490629/article/details/105145126