当前位置:网站首页>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.txtSecond, 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/bashUse -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.txt111222aaaThree, 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 file02Four, 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
边栏推荐
- time complexity and space complexity
- 磁盘管理与文件系统
- User and user group management, file permission management
- spark source code - task submission process - 3-ApplicationMaster
- sql server duplicate values are counted after
- 微信小程序页面跳转传参
- transport layer protocol
- [Problem has been resolved]-Virtual machine error contains a file system with errors check forced
- What are some things that you only know when you do operation and maintenance?
- wc、grep、tar、vi/vim
猜你喜欢
随机推荐
RAID disk array
selenium模块的操作之拉钩
NAT实验
深度 Zabbix 使用指南——来自惨绿少年
Technology Sharing Miscellaneous Technologies
The spark operator - repartition operator
Unity realizes first-person roaming (nanny-level tutorial)
Hugo搭建个人博客
正则表达式小示例--获取重复最多的字符及其数量
IP address and subnet division
IP packet format (ICMP protocol and ARP protocol)
NIO工作方式浅析
7步完成云上监控
spark source code - task submission process - 5-CoarseGrainedExecutorBackend
网络不通?服务丢包?看这篇就够了
Autoware--Beike Tianhui rfans lidar uses the camera & lidar joint calibration file to verify the fusion effect of point cloud images
The problem come from line screening process
多线程之传递参数
VRRP概述及实验
七种让盒子水平垂直居中的方法









