Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 使用awk或sed提取文本_Regex_Linux_Text_Awk_Sed - Fatal编程技术网

Regex 使用awk或sed提取文本

Regex 使用awk或sed提取文本,regex,linux,text,awk,sed,Regex,Linux,Text,Awk,Sed,我想从下面摘录并删除一些文本 [root@test]du-k./[a-zA-Z0-9]-最大深度=1 |分拣-小时 以前 7789696 ./b/bklee 946792 ./a 796588 ./b/bluecyn 477860 ./b/bborikun 473652 ./b/bluechiper 220780 ./a/ara316 144244 ./a/aceload 131088 ./b/belivart

我想从下面摘录并删除一些文本

[root@test]du-k./[a-zA-Z0-9]-最大深度=1 |分拣-小时

以前

    7789696 ./b/bklee
    946792  ./a
    796588  ./b/bluecyn
    477860  ./b/bborikun
    473652  ./b/bluechiper
    220780  ./a/ara316
    144244  ./a/aceload
    131088  ./b/belivart
    79108   ./a/athlon85
    78644   ./b/beschur512
    66264   ./b/bogdanov
    52460   ./A
之后

我想要的是删除重复的模式、/a/和只像/a一样打印的行 我正在努力想办法,但由于我是AWK和SED的初学者,我需要一些帮助

谢谢

像这样,使用GNU:

    796588  bluecyn
    477860  bborikun
    473652  bluechiper
    220780  ara316
    144244  aceload
    131088  belivart
    79108   athlon85
    78644   beschur512
    66264   bogdanov
sed -E '/\s\.\/\w$/d; s!\./\w/?!!' file
7789696 bklee
796588 bluecyn
477860 bborikun
473652 bluechiper
220780 ara316
144244 aceload
131088 belivart
79108 athlon85
78644 beschur512
66264 bogdanov
du -k ./[a-zA-Z0-9] --max-depth=1 | sort -hr | sed -e 's,\./[a-z]/,,; /\.\/[Aa-Zz]/d'

7789696 bklee
796588  bluecyn
477860  bborikun
473652  bluechiper
220780  ara316
144244  aceload
131088  belivart
79108   athlon85
78644   beschur512
66264   bogdanov