当前位置:网站首页>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
边栏推荐
- [ingress]-ingress exposes services using tcp port
- spark source code - task submission process - 1-sparkSubmit
- Apache configure reverse proxy
- Will intelligent operation and maintenance replace manual operation and maintenance?
- [问题已处理]-虚拟机报错contains a file system with errors check forced
- 单臂路由实验和三层交换机实验
- One-arm routing and 30% switch
- 产品学习资料
- 618, you may be able to wake up a little bit
- Dry!Teach you to use industrial raspberries pie combining CODESYS configuration EtherCAT master station
猜你喜欢
spark source code-RPC communication mechanism
Dry!Teach you to use industrial raspberries pie combining CODESYS configuration EtherCAT master station
Mongodb query analyzer parsing
input详解之文件上传
vim教程:vimtutor
入职前,没想到他们玩的这么花
Mongodb查询分析器解析
IP packet format (ICMP protocol and ARP protocol)
Mina's long and short connections
Technology Sharing Miscellaneous Technologies
随机推荐
el-progress实现进度条颜色不同
Tencent Cloud Message Queue CMQ
Problems encountered in installing Yolo3 target detection module in Autoware
程序员应该这样理解I/O
King power volume LinkSLA, realize operations engineer is happy fishing
磁盘管理与文件系统
spark source code-RPC communication mechanism
Switch principle
From "dual card dual standby" to "dual communication", vivo took the lead in promoting the implementation of the DSDA architecture
product learning materials
教您简单几步实现工业树莓派正确安装RS232转USB驱动
Autoware--Beike Tianhui rfans lidar uses the camera & lidar joint calibration file to verify the fusion effect of point cloud images
Technology Sharing Miscellaneous Technologies
错误类型:反射。ReflectionException:无法设置属性“xxx”的“类”xxx”与价值“xxx”
618,你也许可以清醒亿点点
Servlet跳转到JSP页面,转发和重定向
Advantages of overseas servers
Spark source code - task submission process - 4-container to start executor
Browser Storage WebStorage
ALC实验