linux下命令行的使用:使用sed命令操作文件

用該命令sed刪除文件test.txt中包含某個字符串abc的行:

sed '/adc/d' test.txt >result.txt

在文件test.txt中刪除從開頭到含有某個字符串abc的行?

?sed?'1,/abc/d' test.txt?>result.txt

獲取文件test.txt中包含字符串abc的行

cat test.txt |grep "abc" > result.txt

sed具體用法如下:?

用法: sed [選項]... {腳本(如果沒有其他腳本)} [輸入文件]...

-n, --quiet, --silent
取消自動打印模式空間
-e 腳本, --expression=腳本
添加“腳本”到程序的運行列表
-f 腳本文件, --file=腳本文件
添加“腳本文件”到程序的運行列表
--follow-symlinks
直接修改文件時跟隨軟鏈接
-i[擴展名], --in-place[=擴展名]
直接修改文件(如果指定擴展名就備份文件)
-l N, --line-length=N
指定“l”命令的換行期望長度
--posix
關閉所有 GNU 擴展
-r, --regexp-extended
在腳本中使用擴展正則表達式
-s, --separate
將輸入文件視為各個獨立的文件而不是一個長的連續輸入
-u, --unbuffered
從輸入文件讀取最少的數據,更頻繁的刷新輸出
--help 打印幫助并退出
--version 輸出版本信息并退出

如果沒有 -e, --expression, -f 或 --file 選項,那么第一個非選項參數被視為
sed腳本。其他非選項參數被視為輸入文件,如果沒有輸入文件,那么程序將從標準
輸入讀取數據。

GNU版sed主頁: <http://www.gnu.org/software/sed/>。
使用GNU軟件所需幫助文檔: <http://www.gnu.org/gethelp/>。
將錯誤報告通過電子郵件發送到:<bug-gnu-utils@gnu.org>.
請務必將單詞“sed”放在標題的某處。

?其他某些用法:http://www.cnblogs.com/dong008259/archive/2011/12/07/2279897.html?

轉載于:https://www.cnblogs.com/xiayexingkong/archive/2013/06/14/3135775.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/274206.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/274206.shtml
英文地址,請注明出處:http://en.pswp.cn/news/274206.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

ux的重要性_UX中清晰的重要性

ux的重要性重點 (Top highlight)Times, since the very first occurrences of web design in the 90’s, have changed a lot design-wise. The particular technology and its applications got more stable. Human-computer interaction (HCI) was deeply researched, design…

工欲善其事,必先利其器

vs2010中一些常用的快捷鍵、組合鍵&#xff1a; 1、快速格式化 CtrlED 2、注釋選中部分 CtrlEC 3、停止調試 ShiftF5 4、取消注釋選中部分 CtrlEU 5、顯示解決方案資源管理器 CtrlWS 6、快速折疊 CtrlMO 7、封裝一個字段 CtrlRE 8、查看屬性 CtrlWP 9…

可靠消息最終一致性設計_如何最終啟動您的設計產品組合

可靠消息最終一致性設計It’s not a secret that most designers procrastinate on their portfolios whether it is to update them or to create them in the first place.大多數設計師在更新產品組合時還是拖延產品組合并不是秘密。 首先創建它們 。 Hopefully, by the e…

臺式機共享筆記本的無線網絡(只需要一根網線)

以windowsXP系統為例 一、筆記本的設置方法&#xff1a; 1.先將筆記本的無線連接共享給有線網卡 將鼠標放到桌面的 網上鄰居 上&#xff0c;按鼠標右鍵&#xff0c;選屬性&#xff0c;再將鼠標放到無線連接上&#xff0c;又是按鼠標右鍵&#xff0c;選屬性&#xff0c;在彈出的…

游戲用戶體驗指標_電子游戲如何超越游戲化的用戶體驗

游戲用戶體驗指標游戲UX (GAMES UX) During a time when the time spent on video games has reached record breaking heights, due to excessive time indoors, gamification has more of a place now than ever before.d uring的時候花在視頻游戲的時間已經達到了 破紀錄的高…

JAVA編程心得-JAVA實現CRC-CCITT(XMODEM)算法

CRC即循環冗余校驗碼&#xff08;Cyclic Redundancy Check&#xff09;&#xff1a;是數據通信領域中最常用的一種差錯校驗碼&#xff0c;其特征是信息字段和校驗字段的長度可以任意選定。 1 byte checksum CRC-16 CRC-16 (Modbus) CRC-16 (Sick) …

什么字體字母和數字大小一樣_字母和字體如何適應我們的屏幕

什么字體字母和數字大小一樣Writing went through many iterations before it became what is today. Times New Roman wasn’t the default script for ancient Egyptians, in fact, paper didn’t even exist when the first words were written.寫作經歷了許多迭代&#xff…

jenkins 通過批處理自動構建 非標準項目

之前介紹了java和vs2010的項目構建&#xff0c;這些都是比較常見的&#xff0c;所以都用專門的工具。但但難免會遇到一些不常見的項目&#xff0c;下面介紹通過批處理進行構建&#xff0c;并用jenkins調用.我們這里使用plc語言&#xff0c;沒有標準環境&#xff0c;只有使用bat…

效果圖底圖 線框圖_5分鐘的線框圖教程

效果圖底圖 線框圖為什么使用線框&#xff1f; (Why wireframe?) Simply put, wireframes provide a structure and layout for content and assets.簡而言之&#xff0c;線框提供了內容和資產的結構和布局。 You can wireframe just about any kind of presentation, from p…

多線程 - 你知道線程棧嗎

問題 1. local 變量的壓棧和出棧過程 void func1(){ int a 0; int b 0; } 系統中有一個棧頂指針&#xff0c;每次分配和回收local 變量時&#xff0c;其實就是移動棧指針。 2. static local變量的分配風險 void func2(){ static int a 0; } 這個變量a可能會被分…

怎么讓qt發聲_第3部分:添加網絡字體-讓我們的單詞發聲

怎么讓qt發聲This is a big week for the project. While it was an important step last week to establish some basic responsiveness, we couldn’t really nail down the typography until we added the typeface. Too many aspects of the feel, proportions, and overal…

mysql語句中把string類型字段轉datetime類型

mysql語句中把string類型字段轉datetime類型在mysql里面利用str_to_date&#xff08;&#xff09;把字符串轉換為日期此處以表h_hotelcontext的Start_time和End_time字段為例&#xff0c;查詢當前時間在此范圍之內的數據。 www.2cto.com select * from h_hotelcontext where …

名詞解釋:對等知識互聯網_網站設計理論:比較和對等

名詞解釋:對等知識互聯網Equivalence and contrast, connection and distinction, categorization and non-categorization are all ways to distinguish the same or different elements. Based on the information they carry, we hope that the equivalent elements can hav…

hadoop深入研究:(五)——Archives

轉載請注明來源地址&#xff1a;http://blog.csdn.net/lastsweetop/article/details/9123155 簡介 我們在hadoop深入研究:(一)——hdfs介紹里已講過&#xff0c;hdfs并不擅長存儲小文件&#xff0c;因為每個文件最少一個block&#xff0c;每個block的元數據都會在namenode節點占…

人民幣小寫金額轉大寫金額

#region 人民幣小寫金額轉大寫金額/// <summary>/// 小寫金額轉大寫金額/// </summary>/// <param name"Money">接收需要轉換的小寫金額</param>/// <returns>返回大寫金額</returns>public static string ConvertMoney(Decimal…

饑餓的盛世讀后感_滿足任何設計師饑餓感的原型制作工具

饑餓的盛世讀后感Tell me if this story sounds familiar to you. You just wrapped up a design in Sketch -a design that took you hours, and now you want to bring it to life. Sketch’s built-in prototyping tool doesn’t allow you to create all the interactions …

關于軟件版本的說明

Trial&#xff1a;試用版&#xff0c;軟件在功能或時間上有所限制&#xff0c;如果想解除限制&#xff0c;需要購買零售版。 Retail&#xff1a;零售版。Free&#xff1a;免費版。Full&#xff1a;完全版。Alpha&#xff1a;內部測試版&#xff0c;通常在Beta版發布之前推出。…

figma 安裝插件_我制作Figma插件的經驗

figma 安裝插件Since Figma released the Figma Community (Beta), I’ve been working on Figma plugins in my free time while I study the code. With the help of an engineer friend of mine, I’ve developed four small plugins so far. As I continue to update these…

術語解釋_術語

術語解釋Colour has a great impact in the world around us and this is no different in User Interfaces (UI). However, it’s not always given the importance it deserves. Sometimes colour is understood as a purely aesthetic element that is completely relative …

安卓中的對話框通知---簡單的對話框入門

當你的應用需要顯示一個進度條或需要用戶對信息進行確認時&#xff0c;可以使用對話框來完成。 1、用一個按鈕來進行測試&#xff0c;在layout文件中的activity_main.xml文件中添加一個Button按鈕&#xff1a; <RelativeLayout xmlns:android"http://schemas.android.c…