Linux shell编程学习笔记49:strings命令

0 前言

在使用Linux的过程中,有时我们需要在obj文件或二进制文件中查找可打印的字符串,那么可以strings命令。

1. strings命令 的功能、格式和选项说明

我们可以使用命令 strings --help 来查看strings命令的帮助信息。

pupleEndurer @ bash ~ $ strings --help
Usage: strings [option(s)] [file(s)]
 Display printable strings in [file(s)] (stdin by default)
 The options are:
  -a - --all                Scan the entire file, not just the data section [default]
  -d --data                 Only scan the data sections in the file
  -f --print-file-name      Print the name of the file before each string
  -n --bytes=[number]       Locate & print any NUL-terminated sequence of at
  -<number>                   least [number] characters (default 4).
  -t --radix={o,d,x}        Print the location of the string in base 8, 10 or 16
  -w --include-all-whitespace Include all whitespace as valid string characters
  -o                        An alias for --radix=o
  -T --target=<BFDNAME>     Specify the binary file format
  -e --encoding={s,S,b,l,B,L} Select character size and endianness:
                            s = 7-bit, S = 8-bit, {b,l} = 16-bit, {B,L} = 32-bit
  -s --output-separator=<string> String used to separate strings in output.
  @<file>                   Read options from <file>
  -h --help                 Display this information
  -v -V --version           Print the program's version number
strings: supported targets: elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex
Report bugs to <http://bugzilla.redhat.com/bugzilla/>

1.1 strings命令的功能

显示文件中可打印的字符串。

1.2 strings命令的格式

strings [选项(s)] [文件(s)]

 1.3 strings命令的选项说明 

选项说明

-a

--all

-

扫描整个文件而不是只扫描目标文件初始化和装载段

-d

--data

仅打印文件中已初始化、加载的数据段中的字符串,这可能会减少输出中的垃圾量

-e <encoding>

--encoding=<s,S,b,l,B,L>

选择字符编码与字节序。可取值:

s=7bits的ASCII, S=8bits的Latin1, {b,l}=16bits宽字符大小端编码, {B,L}=32bits宽字符大小端编码。其中b,B代表bigendian,l,L代表littleendian

-f

–-print-file-name

在显示字符串前先显示文件名
--help显示帮助信息

-<min-len>

-n <min-len>

--bytes=<min-len>

指定可打印字符序列的最小长度,不指定则默认是4个字符
-o类似 --radix=o

-t <radix>

--radix=<radix>

输出字符串在文件中的偏移位置,radix可取值o(octal,八进制)、d(decimal,十进制)或者x(hexadecimal,十六进制)

-T <bfdname>

--target=<bfdname>

指定二进制文件格式

-v

-V

--version

显示版本信息

-w

--include-all-whitespace

默认情况下,Tab和空格字符包含在字符串中,但其他空白字符除外,比如换行符和回车符等字符不是。-w使所有的空白字符被认为是字符串的一部分
@<file>从指定的文件file总读取命令行选项

字符串: 支持的目标: elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex

2 strings命令使用实例

我们先用echo命令创建一个用来演示命令用法的文件a.txt

pupleEndurer @ bash ~ $ echo -e "Hello \t world. \n\r I am PurpleEnduer :-P \a\b ..." > a.txt

然后我们使用cat命令查看文件a.txt的内容

pupleEndurer @ bash ~ $ cat a.txt
Hello    world. 
 I am PurpleEnduer :-P ...

2.1 strings 文件名:查看文件中的可打印字符

pupleEndurer @ bash ~ $ strings a.txt
Hello    world. 
 I am PurpleEnduer :-P 
 ...
pupleEndurer @ bash ~ $ 

 

2.2 strings -f 文件名:在显示字符串前先显示文件名

pupleEndurer @ bash ~ $ strings -f a.txt
a.txt: Hello     world. 
a.txt:  I am PurpleEnduer :-P 
a.txt:  ...
pupleEndurer @ bash ~ $ 

2.3 strings -t x 文件名:以16进制输出字符串在文件中的偏移位置

pupleEndurer @ bash ~ $ strings -t x a.txt
      0 Hello    world. 
     11  I am PurpleEnduer :-P 
     2a  ...
pupleEndurer @ bash ~ $ 

2.4 strings -e 字符编码与字节序 文件名:输出符合指定字符编码与字节序的可打印字符串

 pupleEndurer @ bash ~ $ strings -e S a.txt
Hello    world. 
 I am PurpleEnduer :-P 
 ...
pupleEndurer @ bash ~ $ strings -e{b,l} a.txt
pupleEndurer @ bash ~ $ strings -e{B,L} a.txt
pupleEndurer @ bash ~ $ strings -es a.txt
Hello    world. 
 I am PurpleEnduer :-P 
 ...
pupleEndurer @ bash ~ $ 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/13139.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

在k8s中搭建elasticsearch高可用集群,并对数据进行持久化存储

&#x1f407;明明跟你说过&#xff1a;个人主页 &#x1f3c5;个人专栏&#xff1a;《洞察之眼&#xff1a;ELK监控与可视化》&#x1f3c5; &#x1f516;行路有良友&#xff0c;便是天堂&#x1f516; 目录 一、引言 1、Elasticsearch简介 2、k8s简介 二、环境准备 …

Git项目管理——提交项目和版本回退(二)

个人名片&#xff1a; &#x1f393;作者简介&#xff1a;嵌入式领域优质创作者&#x1f310;个人主页&#xff1a;妄北y &#x1f4de;个人QQ&#xff1a;2061314755 &#x1f48c;个人邮箱&#xff1a;[mailto:2061314755qq.com] &#x1f4f1;个人微信&#xff1a;Vir2025WB…

android绘制多个黑竖线条

本文实例为大家分享了android绘制多个黑竖线条展示的具体代码&#xff0c;供大家参考&#xff0c;具体内容如下 1.写一个LinearLayout的布局&#xff0c;将宽度写成5dp将高度写成match_parent. 2.在写一个类继承LinearLayout&#xff0c;用LayoutInflater实现子布局的在这个L…

train_gpt2_fp32.cu - main

llm.c/test_gpt2_fp32.cu at master karpathy/llm.c (github.com) 源码 // ---------------------------------------------------------------------------- // main training loop int main(int argc, char *argv[]) {// read in the (optional) command line argumentsco…

三.使用HashiCorp Vault工具管理数据库

三.ubuntu安装使用HashiCorp Vault工具管理数据库 HashiCorp Vault 是一个基于身份的秘密和加密管理系统。机密是您想要严格控制访问的任何内容,例如 API 加密密钥、密码和证书。Vault 提供由身份验证和授权方法门控的加密服务。使用 Vault 的 UI、CLI 或 HTTP API,可以安全…

深度优先搜索汇总

常用英文 最近公共祖先&#xff08;Lowest Common Ancestor&#xff0c;简称LCA&#xff09; posterity&#xff0c;英语单词&#xff0c;主要用作名词&#xff0c;作名词时译为“子孙&#xff0c;后裔&#xff1b;后代”。 什么是深度优先搜索 深度优先搜索&#xff0c;D…

[前端] vue2的/deep/转化为vue3语法(笔记)

vue2语法示例 <style scoped lang"less">/deep/.el-carousel__button {width: 8px;height: 3px;border-radius: 3px;}/deep/.el-carousel__indicator.is-active button {width: 16px;} } </style>在 Vue 3 中&#xff0c;/deep/ 或 >>> 选择器…

24 内核开发- Linux 内核各种设计模式

24 内核开发- Linux 内核各种设计模式 Linux 内核中使用了各种设计模式来组织和结构其庞大的代码库。以下是 Linux 内核中的一些常见设计模式&#xff1a; 1. 单例模式&#xff1a; 模块&#xff1a; init 模块 目的&#xff1a; 初始化内核并创建第一个进程 (init_task) 实现…

uni-app 实现下拉单选功能(六)

总体的设计思想是,一个输入框在客户点击时,弹出需要选择的下拉框选项,客户选择完后,隐藏下拉框选项内容;并将选择的数据填充到输入框内。话不多说直接上代码: <template> <view class="dianjianInfo"> <view class="uni-form…

文心一言指令

文心一言 文心一言&#xff08;ERNIE Bot&#xff09;是百度公司研发的知识增强大语言模型&#xff0c;它可以根据用户的指令和输入&#xff0c;生成相应的回答或文本。以下是一些可能的指令示例&#xff0c;用于指导文心一言完成不同的任务&#xff1a; 知识问答&#xff1a…

【oracle】图片转为字节、base64编码等形式批量插入oracle数据库并查询

1.熟悉、梳理、总结下Oracle相关知识体系 2.欢迎批评指正&#xff0c;跪谢一键三连&#xff01; 资源下载&#xff1a; oci.dll、oraocci11.dll、oraociei11.dll3个资源文件资源下载&#xff1a; Instant Client Setup.exe资源下载&#xff1a; oci.dll、oraocci11.dll、oraoc…

LangChain_Tools

1、Tools 可以被Agent、Chain、LLM所使用。 2、tool 的必备属性有&#xff1a;name、description、JSON schema &#xff08;tool输入&#xff09;、调用的函数、工具的结果是否应直接返回给用户。其中name、description和 JSON schema 可用于提示 LLM、写入在LLM的system pro…

初识C语言——第二十一天

猜数字小游戏的实现&#xff1a; 学会了之后可以自己制作彩票抽奖&#xff0c;哈哈&#xff01; 代码实现&#xff1a; #include <stdlib.h> #include <time.h>void menu()//无返回值函数 {printf("**************************\n");printf("****…

Linux:退出vim编辑模式

一、使用快捷键进行退出 1、按“Esc”键进入命令模式 当我们在vim编辑模式下输入完毕需要进行退出操作时&#xff0c;首先需要按下“Esc”键&#xff0c;将vim编辑器从插入模式或者替换模式切换到命令模式。 ESC 2、输入“:wq”保存并退出 在命令模式下&#xff0c;输入“:…

在kubernetes中配置Ingress

目录 1. 安装Nginx Ingress Controller2. 准备TLS证书3. 编写Ingress资源定义4. 应用Ingress配置5. 验证配置 1. 安装Nginx Ingress Controller 首先&#xff0c;确保你的Kubernetes集群已经准备好。你可以使用Helm或者直接通过yaml文件来安装Nginx Ingress Controller。这里给…

云原生 初识Kubernetes的理论基础

一、k8s 的由来及其技术运用 1.1 k8s的简介 Kubernetes&#xff0c;词根源于希腊语的 舵手、飞行员。在国内又称k8s&#xff08;因为k和s之间有8个字母&#xff0c;所以得名。“国内程序员的幽默”&#xff09;。 作用&#xff1a; 用于自动部署、扩展和管理“容器化&#x…

利用远程控制软件FinalShell远程连接虚拟机上的Linux系统(Windows)

一. VMware Workstation 安装CentOS Linux操作系统 传送门&#xff1a;VMware Workstation 安装CentOS Linux操作系统 1.右键打开终端 2.输入ifconfig 找到ens33对应 inet的id&#xff0c;这个就是虚拟机的ip地址图中所示为&#xff1a;192.168.5.128 3.打开finalshell 如…

如何使用 PuTTY 创建 SSH 密钥以连接到 VPS

公钥和私钥 SSH 密钥的好处 如果您的无头或远程 VPS 可以通过互联网访问&#xff0c;您应该尽可能使用公钥身份验证而不是密码。这是因为与仅使用密码相比&#xff0c;SSH 密钥提供了一种更安全的登录方式。虽然密码最终可以通过暴力破解攻击破解&#xff0c;但 SSH 密钥几乎不…

C++ | Leetcode C++题解之第92题反转链表II

题目&#xff1a; 题解&#xff1a; class Solution { public:ListNode *reverseBetween(ListNode *head, int left, int right) {// 设置 dummyNode 是这一类问题的一般做法ListNode *dummyNode new ListNode(-1);dummyNode->next head;ListNode *pre dummyNode;for (i…

抽象类介绍

抽象类 【一】什么是抽象 # 将某几个具体的生物&#xff0c;根据特征总结成一个类&#xff0c;逐层向上总结 # 唐老鸭 肉鸭 北京烤鸭 ---> 鸭子 # 北极熊 黑熊 --> 熊 # 猫 老虎 --> 猫科 # 鸭子 熊 猫科 --> 动物 【二】什么是继承 # 动物 ---> 熊 --->…