Skip to content

Commit

Permalink
post(sed): fix command positions
Browse files Browse the repository at this point in the history
  • Loading branch information
l-lin committed Feb 25, 2020
1 parent ac2b916 commit 694ac19
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions content/post/2020/2020-02-14-sed.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ imageUrl: "https://images.pexels.com/photos/207580/pexels-photo-207580.jpeg?auto
tags: ["terminal"]
categories: ["post"]
comment: true
toc: false
toc: true
autoCollapseToc: false
contentCopyright: false
---
Expand Down Expand Up @@ -41,6 +41,9 @@ sed '/foobar/!s/pattern/replacement/g'

# if you want to edit files in place, add the flag "-i"
sed -i 's/pattern/replacement/g' filename.txt

# replace commas with newlines (use \r, not \n)
sed 's/,/\r/g'
```

## Selective deletion
Expand All @@ -63,12 +66,6 @@ sed '1,10d'

# delete ALL blank lines
sed '/^$/d'

# replace commas with newlines (use \r, not \n)
sed 's/,/\r/g'

# insert 2 blank spaces at beginning of each line
sed 's/^/ /'
```

## Print
Expand Down Expand Up @@ -108,5 +105,8 @@ sed '/pattern/i foobar'
sed '2a foobar'
# prepend "foobar" before 2nd line
sed '2i foobar'

# insert 2 blank spaces at beginning of each line
sed 's/^/ /'
```

0 comments on commit 694ac19

Please sign in to comment.