Skip to content

Latest commit

 

History

History
35 lines (31 loc) · 812 Bytes

9.md

File metadata and controls

35 lines (31 loc) · 812 Bytes

题目要求

把一个文本文档的前5行中包含字母的行删除掉,同时把6到10行中的全部字母删除掉。

核心要点

sed命令

参考答案

#!/bin/bash
sed -n '1,5'p 1.txt |sed '/[a-zA-Z]/d'
sed '1,5d' 1.txt |sed '1,5s/[a-zA-Z]//g'

示例文件1.txt内容

1111111111111111111
121212aaasdasdf
asdfasdfasdfasdfasdf
12121212aklsdfjaklsdfkjk
*****#)#((@#*@)1121212
root@gitlba-aming shell100
12aaasdas23asdfasdf
asdf;lkjas;lkdjfkl;ajsdf
asl;dkfjalskdjflkj2elkjwlkej23kijlkjasdf
laksjdflkjslkdjfslkdjflksjdf
21l3k2l3k2l3kjl2k3jl2k3j
askdjfklasjdflklkajlksdjfkl12323232323
asdklfjalksdf
asldkfjalksdjfalksdjfklasjdf2323
aslkdjflk2k3j2lk3jl2k3j
asdklfjalksjdflkj132
asdfkjalksdjf121adfavasdfads asldkfjalksdjf
lkjlkjlwkerlk2j3lk21j3lkjflkasjdlkj23lkj klaj d