iis服务器助手广告广告
返回顶部
首页 > 资讯 > 操作系统 >Linux文本如何查看命令及其选项
  • 906
分享到

Linux文本如何查看命令及其选项

2023-06-09 12:06:42 906人浏览 安东尼
摘要

小编给大家分享一下linux文本如何查看命令及其选项,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!什么是Linux系统Linux是一种免费使用和自由传播的类UNI

小编给大家分享一下linux文本如何查看命令及其选项,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

什么是Linux系统

Linux是一种免费使用和自由传播的类UNIX操作系统,是一个基于POSIX的多用户、多任务、支持多线程和多CPU的操作系统,使用Linux能运行主要的Unix工具软件、应用程序和网络协议。

linux系统内置命令可以通过以下两种方式查询:“cat --help” 或者“man cat”。

cat命令的常用选项和官方解释如下:

cat file_name 显示文件全部内容

cat -b file_name 显示文件非空行内容

cat -E file_name 在文件每行末尾显示$,常用于管道功能

cat -n file_name 显示内容和行号

Usage: cat [OPTioN]... [FILE]...Concatenate FILE(s) to standard output.With no FILE, or when FILE is -, read standard input. -A, --show-all      equivalent to -vET -b, --number-nonblank  number nonempty output lines, overrides -n -e            equivalent to -vE -E, --show-ends     display $ at end of each line -n, --number       number all output lines -s, --squeeze-blank   suppress repeated empty output lines -t            equivalent to -vT -T, --show-tabs     display TAB characters as ^I -u            (ignored) -v, --show-nonprinting  use ^ and M- notation, except for LFD and TAB   --help   display this help and exit   --version output version infORMation and exitExamples: cat f - g Output f's contents, then standard input, then g's contents. cat    Copy standard input to standard output.GNU coreutils online help: <Http://www.gnu.org/software/coreutils/>Full documentation at: http://www.gnu.org/software/coreutils/cat

head命令及其选项如下:

head -c10 file_name 显示一开始的10个字节

head -c-10 file_name 显示除末尾10个字节之外的内容

head -n10 file_name 显示一开始的10行内容

head -n-10 file_name 显示除末尾的10行之外的内容

Usage: head [OPTION]... [FILE]...Print the first 10 lines of each FILE to standard output.With more than one FILE, precede each with a header giving the file name.With no FILE, or when FILE is -, read standard input.Mandatory arguments to long options are mandatory for short options too. -c, --bytes=[-]NUM    print the first NUM bytes of each file;               with the leading '-', print all but the last               NUM bytes of each file -n, --lines=[-]NUM    print the first NUM lines instead of the first 10;               with the leading '-', print all but the last               NUM lines of each file -q, --quiet, --silent  never print headers giving file names -v, --verbose      always print headers giving file names -z, --zero-terminated  line delimiter is NUL, not newline   --help   display this help and exit   --version output version information and exitNUM may have a multiplier suffix:b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.GNU coreutils online help: <http://www.gnu.org/software/coreutils/>Full documentation at: http://www.gnu.org/software/coreutils/head

tail命令及其选项如下:

tail -c10 file_name 显示末尾的10个字节

tail -c-10 file_name 显示除开头10个字节之外的内容

tail -n10 file_name 显示末尾的10行内容

tail -n-10 file_name 显示除开头的10行之外的内容

Usage: tail [OPTION]... [FILE]...Print the last 10 lines of each FILE to standard output.With more than one FILE, precede each with a header giving the file name.With no FILE, or when FILE is -, read standard input.Mandatory arguments to long options are mandatory for short options too. -c, --bytes=[+]NUM    output the last NUM bytes; or use -c +NUM to               output starting with byte NUM of each file -f, --follow[={name|descriptor}]              output appended data as the file grows;               an absent option argument means 'descriptor' -F            same as --follow=name --retry -n, --lines=[+]NUM    output the last NUM lines, instead of the last 10;               or use -n +NUM to output starting with line NUM   --max-unchanged-stats=N              with --follow=name, reopen a FILE which has not               changed size after N (default 5) iterations               to see if it has been unlinked or renamed               (this is the usual case of rotated log files);               with inotify, this option is rarely useful   --pid=PID      with -f, terminate after process ID, PID dies -q, --quiet, --silent  never output headers giving file names   --retry       keep trying to open a file if it is inaccessible -s, --sleep-interval=N  with -f, sleep for approximately N seconds               (default 1.0) between iterations;               with inotify and --pid=P, check process P at               least once every N seconds -v, --verbose      always output headers giving file names -z, --zero-terminated  line delimiter is NUL, not newline   --help   display this help and exit   --version output version information and exitNUM may have a multiplier suffix:b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.With --follow (-f), tail defaults to following the file descriptor, whichmeans that even if a tail'ed file is renamed, tail will continue to trackits end. This default behavior is not desirable when you really want totrack the actual name of the file, not the file descriptor (e.g., logrotation). Use --follow=name in that case. That causes tail to track thenamed file in a way that accommodates renaming, removal and creation.GNU coreutils online help: <http://www.gnu.org/software/coreutils/>Full documentation at: http://www.gnu.org/software/coreutils/tail

搭配管道使用更佳

此外,这三个命令常常与管道功能搭配,用于文件内容的操作,例如:

对data.txt中的数据进行排序:cat data.txt | sort

对data.txt中的内容匹配:cat data.txt | grep 'a'

输出data.txt中的非空行数:cat -b data.txt | wc -l

以上是“Linux文本如何查看命令及其选项”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注编程网操作系统频道!

--结束END--

本文标题: Linux文本如何查看命令及其选项

本文链接: https://www.lsjlt.com/news/255897.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Linux文本如何查看命令及其选项
    小编给大家分享一下Linux文本如何查看命令及其选项,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!什么是Linux系统Linux是一种免费使用和自由传播的类UNI...
    99+
    2023-06-09
  • Linux如何查看命令详细使用参数和选项
    本篇内容主要讲解“Linux如何查看命令详细使用参数和选项”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Linux如何查看命令详细使用参数和选项”吧! ...
    99+
    2023-02-13
    linux
  • linux如何使用cat命令查看文件
    这篇文章给大家分享的是有关linux如何使用cat命令查看文件的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。什么是Linux系统Linux是一种免费使用和自由传播的类UNIX操作系统,是一个基于POSIX的多用户...
    99+
    2023-06-13
  • linux如何查看历史命令
    这篇文章将为大家详细讲解有关linux如何查看历史命令,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。linux查看历史命令可以使用history命令,该命令可以列出所有已键入的命令。用户所键入的命令都会记...
    99+
    2023-06-14
  • Linux系统如何查看NGINX版本信息命令
    这篇“Linux系统如何查看NGINX版本信息命令”文章,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要参考一下,对于“Linux系统如何查看NGINX版本信息命令”,小编整理了以下知识点,请大家跟着小编的步伐一步一...
    99+
    2023-06-28
  • Linux下怎么使用more命令查看文本文件
    这篇文章主要介绍了Linux下怎么使用more命令查看文本文件的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇Linux下怎么使用more命令查看文本文件文章都会有所收获,下面我们一起来看看吧。基础使用假设你现在...
    99+
    2023-06-27
  • 如何在linux中使用less命令查看文件
    如何在linux中使用less命令查看文件?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。1.命令格式:less [参数]  文件2.命令功能:less...
    99+
    2023-06-09
  • linux查看文件命令是什么
    这篇文章主要介绍“linux查看文件命令是什么”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“linux查看文件命令是什么”文章能帮助大家解决问题。除vi的其他查看文件的命令:1、cat命令,可显示文...
    99+
    2023-07-02
  • 如何使用命令查看mysql版本
    这篇文章给大家介绍如何使用命令查看mysql版本,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。1、在mysql的命令窗口状态下:status;回车即可2、在mysql命令状态下:select version();回车即...
    99+
    2023-06-15
  • Linux中怎么查看MySQL版本命令
    本篇内容介绍了“Linux中怎么查看MySQL版本命令”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成! mysql -V或...
    99+
    2023-06-28
  • linux查看本机ip命令有哪些
    linux中查看本机ip的命令有:1.ifconfig命令,用于显示或设置网络设备;2.ip命令,用于执行网络管理任务;linux中查看本机ip的命令有以下两种ifconfig命令linux中ifconfig命令的作用是用于显示或设置网络设...
    99+
    2024-04-02
  • 不可不知的Linux文本查看命令有哪些
    小编给大家分享一下不可不知的Linux文本查看命令有哪些,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!全文本显示--catcat可能是常用的一个文本查看命令了,使...
    99+
    2023-06-15
  • linux如何查看历史执行命令
    在Linux系统中,可以使用以下几种方法来查看历史执行命令: 使用 history 命令:直接在终端输入 history 命令,...
    99+
    2024-04-02
  • 如何查看Linux硬件信息命令
    这篇文章主要为大家展示了“如何查看Linux硬件信息命令”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“如何查看Linux硬件信息命令”这篇文章吧。1、 主板信息 查看主板的序列号  ------...
    99+
    2023-06-16
  • linux系统如何查看日志命令
    这篇“linux系统如何查看日志命令”文章,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要参考一下,对于“linux系统如何查看日志命令”,小编整理了以下知识点,请大家跟着小编的步伐一步一步的慢慢理解,接下来就让我们...
    99+
    2023-06-28
  • Linux中如何用命令查看端口
    本篇文章为大家展示了Linux中如何用命令查看端口,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。在Linux使用过程中会因为某种需要查看端口,可以使用lost和netstat命令。lsoflsof(...
    99+
    2023-06-28
  • linux如何查看文本内容
    这篇文章主要介绍“linux如何查看文本内容”,在日常操作中,相信很多人在linux如何查看文本内容问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”linux如何查看文本内容”的疑惑有所帮助!接下来,请跟着小编...
    99+
    2023-06-30
  • linux中如何使用type查看命令
    这篇文章主要为大家展示了“linux中如何使用type查看命令”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“linux中如何使用type查看命令”这篇文章吧。type 查看命令类型,例如该命令是...
    99+
    2023-06-04
  • 如何在linux命令行查看ascii码
    这篇文章主要为大家展示了“如何在linux命令行查看ascii码”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“如何在linux命令行查看ascii码”这篇文章吧。命令行查看ascii码我们在开发...
    99+
    2023-06-27
  • linux查看文件夹命令有哪些
    linux中查看文件夹的命令有:1.cat命令,连接文件并打印到标准输出设备上;2.more命令,将文件以一页一页的形式显示;3.head命令,显示指定文件的前若干行;4.tail命令,显示指定文件的末尾若干行;5.ls命令,列出目录文件;...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作