Linux grep | ps

2023-12-16 16:47:44

1 grep -r 'main' ./ -n

zfang@ubuntu:~/Desktop/test/inet$ grep -r 'main' ./ -n
./server.c:5:int main() {
./client.c:6:int main() {?? ?
Binary file ./server.out matches
Binary file ./client.out matches

2 ps -aux

zfang@ubuntu:~/Desktop/test/inet$ ps -aux
USER?????? PID %CPU %MEM??? VSZ?? RSS TTY????? STAT START?? TIME COMMAND
root???????? 1? 0.0? 0.2? 23928? 4240 ???????? Ss?? 12:55?? 0:06 /sbin/init auto
root???????? 2? 0.0? 0.0????? 0???? 0 ???????? S??? 12:55?? 0:00 [kthreadd]
root???????? 3? 0.0? 0.0????? 0???? 0 ???????? S??? 12:55?? 0:00 [ksoftirqd/0]

3 ps -aux | grep 'kernal'

zfang@ubuntu:~/Desktop/test/inet$ ps -aux | grep 'kernal'
zfang???? 9692? 0.0? 0.0?? 5112?? 848 pts/2??? S+?? 15:19?? 0:00 grep --color=auto kernal

4 find ./ -type f | ls -l

zfang@ubuntu:~/Desktop/test/inet$ find ./ -type f | ls -l
total 28
-rw-rw-r-- 1 zfang zfang? 704 Mar 12? 2023 client.c
-rwxrwxr-x 1 zfang zfang 7720 Mar 12? 2023 client.out
-rw-rw-r-- 1 zfang zfang 1029 Mar 12? 2023 server.c
-rwxrwxr-x 1 zfang zfang 7860 Mar 12? 2023 server.out
drwxrwxr-x 2 zfang zfang 4096 Dec 16 15:26 ts


5 find ./ -type f | xargs ls -l

zfang@ubuntu:~/Desktop/test/inet$ find ./ -type f | xargs ls -l
-rw-rw-r-- 1 zfang zfang? 704 Mar 12? 2023 ./client.c
-rwxrwxr-x 1 zfang zfang 7720 Mar 12? 2023 ./client.out
-rw-rw-r-- 1 zfang zfang 1029 Mar 12? 2023 ./server.c
-rwxrwxr-x 1 zfang zfang 7860 Mar 12? 2023 ./server.out

6 find ./ -type f -exec ls -l {} \;

zfang@ubuntu:~/Desktop/test/inet$ find ./ -type f -exec ls -l {} \;
-rw-rw-r-- 1 zfang zfang 1029 Mar 12? 2023 ./server.c
-rw-rw-r-- 1 zfang zfang 704 Mar 12? 2023 ./client.c
-rwxrwxr-x 1 zfang zfang 7860 Mar 12? 2023 ./server.out
-rwxrwxr-x 1 zfang zfang 7720 Mar 12? 2023 ./client.out

7 find ./ -type f | xargs ls -l

zfang@ubuntu:~/Desktop/test/inet$ find ./ -type f | xargs ls -l
ls: cannot access './abc': No such file or directory
ls: cannot access 'xyz': No such file or directory
-rw-rw-r-- 1 zfang zfang? 704 Mar 12? 2023 ./client.c
-rwxrwxr-x 1 zfang zfang 7720 Mar 12? 2023 ./client.out
-rw-rw-r-- 1 zfang zfang 1029 Mar 12? 2023 ./server.c
-rwxrwxr-x 1 zfang zfang 7860 Mar 12? 2023 ./server.out


8 find ./ -type f -print0 | xargs -print0 ls -l

zfang@ubuntu:~/Desktop/test/inet$ find ./ -type f -print0 | xargs -print0 ls -l
xargs: WARNING: a NUL character occurred in the input.? It cannot be passed through in the argument list.? Did you mean to use the --null option?
ls -l ?...y
total 28
-rw-rw-r-- 1 zfang zfang??? 0 Dec 16 15:35 abc xyz
-rw-rw-r-- 1 zfang zfang? 704 Mar 12? 2023 client.c
-rwxrwxr-x 1 zfang zfang 7720 Mar 12? 2023 client.out
-rw-rw-r-- 1 zfang zfang 1029 Mar 12? 2023 server.c
-rwxrwxr-x 1 zfang zfang 7860 Mar 12? 2023 server.out
drwxrwxr-x 2 zfang zfang 4096 Dec 16 15:26 ts

9 find ../ -size +1k -size -10k -print0 | xargs -print0 ls -l -print0 ls -l

zfang@ubuntu:~/Desktop/test/inet$ find ../ -size +1k -size -10k -print0 | xargs -print0 ls -l
xargs: WARNING: a NUL character occurred in the input.? It cannot be passed through in the argument list.? Did you mean to use the --null option?
ls -l ?...y
total 28
-rw-rw-r-- 1 zfang zfang??? 0 Dec 16 15:35 abc xyz
-rw-rw-r-- 1 zfang zfang? 704 Mar 12? 2023 client.c
-rwxrwxr-x 1 zfang zfang 7720 Mar 12? 2023 client.out
-rw-rw-r-- 1 zfang zfang 1029 Mar 12? 2023 server.c
-rwxrwxr-x 1 zfang zfang 7860 Mar 12? 2023 server.out
drwxrwxr-x 2 zfang zfang 4096 Dec 16 15:26 ts

文章来源:https://blog.csdn.net/www586089/article/details/135033192
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。