当前位置:网站首页>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
边栏推荐
- Transport layer protocol (TCP 3-way handshake)
- [问题已处理]-jenkins流水线checkout超时
- Spark source code - task submission process - 4-container to start executor
- Quick question and quick answer - FAQ of Tencent Cloud Server
- Browser Storage WebStorage
- The idea of commonly used shortcut key
- 程序员应该这样理解I/O
- 7步完成云上监控
- 千亿IT运维市场,产品要凭实力说话
- sql server duplicate values are counted after
猜你喜欢

Problems encountered in installing Yolo3 target detection module in Autoware
![[问题已处理]-虚拟机报错contains a file system with errors check forced](/img/07/1222a44dd52b359bf7873e6f3b7ebf.png)
[问题已处理]-虚拟机报错contains a file system with errors check forced

What's the point of monitoring the involution of the system?

spark operator - map vs mapPartitions operator
时间复杂度和空间复杂度

技术分享杂七杂八技术

Dry!Teach you to use industrial raspberries pie combining CODESYS configuration EtherCAT master station

Mina的长连接和短连接

Growth: IT Operations Trends Report

disabledDate 日期选择器 datePicker
随机推荐
LeetCode中常用语言的一些基本方法记录
The Servlet to jump to the JSP page, forwarding and redirection
[issue resolved] - jenkins pipeline checkout timeout
Programmers should understand I/O this way
One-arm routing and 30% switch
I217-V network disconnection problem in large traffic under openwrt soft routing
From "dual card dual standby" to "dual communication", vivo took the lead in promoting the implementation of the DSDA architecture
[Problem has been resolved]-Virtual machine error contains a file system with errors check forced
spark source code - task submission process - 5-CoarseGrainedExecutorBackend
产品学习资料
Apache configure reverse proxy
LeetCode面试题
link 和@improt的区别
七种让盒子水平垂直居中的方法
Dry!Teach you to use industrial raspberries pie combining CODESYS configuration EtherCAT master station
5分钟完成mysql离线安装
selenium模块的操作之拉钩
Will intelligent operation and maintenance replace manual operation and maintenance?
Insight into the general trend of the Internet, after reading this article, you will have a thorough understanding of Chinese domain names
微信小程序页面跳转传参