当前位置:网站首页>wc, grep, tar, vi/vim
wc, grep, tar, vi/vim
2022-08-05 06:22:00 【sologuai】
One, wc
Command format:
wc [options]... target file.. (without options, the default count of lines, words, and bytes)
- -l: count lines
- -w: count the number of words
- -c: count bytes
[[email protected] test]# wc -l 1.txt //Count the number of lines, note that blank lines will also be counted4 1.txt[[email protected] test]# wc -w 1.txt //Count the number of words3 1.txt[[email protected] test]# wc -c 1.txt //Count the number of bytes, note that newline characters will also be counted13 1.txt[[email protected] test]# wc 1.txt //Do not specify options, the default lwc is displayed4 3 13 1.txt
Second, grep
grep is used to find matching strings in a file.
Command format
grep [options]… search criteria target file
- ^..." means start with..., "...$" means end with...
- "^$" means blank line
Use -i "^a" to retrieve the line starting with a, and it is not case-sensitive
[[email protected] ~]# grep -i "^a" /etc/passwdadm:x:3:4:adm:/var/adm:/sbin/nologinabrt:x:173:173::/etc/abrt:/sbin/nologinavahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologinalice:x:1002:1003::/home/alice:/bin/bashAmy:x:1005:1006::/home/Amy:/bin/bash
Use -v "^$" to filter out non-empty lines
[[email protected] test]# cat 123.txt //View the content of the 123.txt file111222aaa[[email protected] test]# grep -v "^$" 123.txt //Filter out non-empty lines111222aaa[[email protected] ~]# cat 123.txt |grep -v '^$' >test.txt //Write non-empty lines to the test.txt file[[email protected] test]# cat test.txt //View test.txt111222aaa
Three, tar
Command format:
tar [options] ... archive filename (tarball name) source file or directory tar [options] ... archive filename [-C target directory]
- -c: Create a package file in .tar format
- -x: Unpack the package file in .tar format
- -C: Specify the target folder to be released when decompressing, specify the directory
- -f: Indicates the use of archive files (usually must be brought to indicate the use of tar)
- -v: output verbose information (Verbose)
- -t: list archive contents
- -j: call bzip2 program to compress or decompress
- -z: call the gzip program to compress or decompress
[[email protected] data]# tar -zcvf vm.tar.gz f1 f2 f3 //Archive the three files and call the gzip program to compress them into vm.tar.gzf1f2f3[[email protected] data]# tar -jcvf vm.tar.bz f1 f2 f3 //Archive the three files and call the bzip2 program to compress them into vm.tar.bz2f1f2f3[[email protected] data]# tar -zxvf vm.tar.gz -C /opt //Extract the vm.tar.gz file to the /opt directoryf1f2f3[[email protected] data]# tar -tf ff.tar.gzip //List archive contentsfile01file02[[email protected] data]# tar -tvf /tmp/ceshi/ff.tar //List all files in the archive in detail (including attribute information)-rwxr--r-- root/root 87 2022-01-21 17:37 file01-rw-r--r-- user01/hr 0 2022-01-19 17:01 file02
Four, vi/vim
vim is a text editor developed from vi.The functions of convenient programming such as code completion, compilation and error jumping are particularly rich, and are widely used by programmers.vim is an enhanced version of the vi text editor.
1.Three working modes of the vim editor
Command mode: After starting the vi editor, it enters the command mode by default. This mode mainly completes related operations such as cursor movement, string search, and deletion, copying, and pasting of file contents;
Input mode: The main operation in this mode is to input the content of the file, you can modify the text of the text file, or add new content.When in input mode, the last line of the vi editor will display a status prompt of "--INSERT--";
Last line mode: In this mode, you can set the vi editing environment, save the file, exit the editor, and perform operations such as searching and replacing the file content.When in last line mode, a colon ":" prompt appears on the last line of the vi editor.
2. Basic operations in command mode
3. Basic operations in last line mode
边栏推荐
猜你喜欢
随机推荐
The Servlet to jump to the JSP page, forwarding and redirection
What?CDN cache acceleration only works for accelerating static content?
CIPU, what impact does it have on the cloud computing industry?
[Problem has been resolved]-Virtual machine error contains a file system with errors check forced
正则表达式小示例--获取重复最多的字符及其数量
[ingress]-ingress使用tcp端口暴露服务
多线程之传递参数
干货!教您使用工业树莓派结合CODESYS配置EtherCAT主站
spark source code-RPC communication mechanism
VRRP principle and command
The size of the screen adaptation
LeetCode中常用语言的一些基本方法记录
Into the pre-service, thought they play so flowers
微信小程序页面跳转传参
Mina's long and short connections
To TrueNAS PVE through hard disk
OpenCV3.0 is compatible with VS2010 and VS2013
618,你也许可以清醒亿点点
From "dual card dual standby" to "dual communication", vivo took the lead in promoting the implementation of the DSDA architecture
监控系统的内卷,有什么讲究?