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.pswp.cn/web/13139.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/13139.shtml
英文地址,請注明出處:http://en.pswp.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;逐層向上總結 # 唐老鴨 肉鴨 北京烤鴨 ---> 鴨子 # 北極熊 黑熊 --> 熊 # 貓 老虎 --> 貓科 # 鴨子 熊 貓科 --> 動物 【二】什么是繼承 # 動物 ---> 熊 --->…