mirror of
https://github.com/onceupon/Bash-Oneliner.git
synced 2024-11-22 21:07:00 +00:00
add sed
remove lines
This commit is contained in:
parent
55e4c097c7
commit
e43853e465
16
README.md
16
README.md
@ -142,6 +142,16 @@ http://www.cyberciti.biz/faq/grep-regular-expressions/
|
|||||||
## Sed
|
## Sed
|
||||||
[[back to top](#handy-bash-oneliner-commands-for-tsv-file-editing)]
|
[[back to top](#handy-bash-oneliner-commands-for-tsv-file-editing)]
|
||||||
|
|
||||||
|
##### Remove the 1st line
|
||||||
|
```bash
|
||||||
|
sed 1d filename
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Remove the 100 lines (remove line 1-100)
|
||||||
|
```bash
|
||||||
|
sed 1,100d filename
|
||||||
|
```
|
||||||
|
|
||||||
##### Remove lines with word (e.g. bbo)
|
##### Remove lines with word (e.g. bbo)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -163,7 +173,7 @@ sed "1i >$i"
|
|||||||
//'1i' means insert to first line
|
//'1i' means insert to first line
|
||||||
|
|
||||||
|
|
||||||
##### Delete empty lines
|
##### Delete/remove empty lines
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sed '/^\s*$/d'
|
sed '/^\s*$/d'
|
||||||
@ -173,13 +183,13 @@ or
|
|||||||
```bash
|
```bash
|
||||||
sed 's/^$/d'
|
sed 's/^$/d'
|
||||||
```
|
```
|
||||||
##### Delete last line
|
##### Delete/remove last line
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sed '$d'
|
sed '$d'
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Delete last character from end of file
|
##### Delete/remove last character from end of file
|
||||||
```bash
|
```bash
|
||||||
sed -i '$ s/.$//' filename
|
sed -i '$ s/.$//' filename
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user