Tuesday, 28 March 2017
sed delete/insert/replace
101. How to delete lines using sed?
delete line 1-3
sed -i '1,3d' test.txt
delete line 2,5,8
sed -i '2d;5d;8d' testComparesllequ*.ll
Remove the line containing the string "awk," by using:
sed '/awk/d' filename.txt
sed -i '/; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py/d'
102. How to insert a line using sed?
sed -i '1 i\
; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu testComparesiequ*.ll
103. sed replace a line:
sed 's/hello/bonjour/' greetings.txt
Replacing in-place -i
sed ships with the -i flag. Let’s consult man sed:
sed -i 's/hello/bonjour/' greetings.txt
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment