Замена вывода на awk или sed

Проще всего использовать специальную программу дупеГуру

dupeGuru Preferences Screenshot

как документация говорит

Deletion Options

These options affect how duplicate deletion takes place. Most of the time, you don’t need to enable any of them.

Link deleted files:

The deleted files are replaced by a link to the reference file. You have a choice of replacing it either with a symlink or a hardlink. ... a symlink is a shortcut to the file’s path. If the original file is deleted or moved, the link is broken. A hardlink is a link to the file itself. That link is as good as a “real” file. Only when all hardlinks to a file are deleted is the file itself deleted.

On OSX and Linux, this feature is supported fully, but under Windows, it’s a bit complicated. Windows XP doesn’t support it, but Vista and up support it. However, for the feature to work, dupeGuru has to run with administrative privileges.

0
13.06.2019, 16:35
2 ответа

Это выглядит как много усилий для чего-то очень тривиального. Вот простая команда sed, которая заменяет «пользователи» на «пользователь» в выводе uptime:

$ uptime | sed 's/users/user/'
 12:28:39 up 17:16,  7 user,  load average: 1.67, 1.41, 1.31
1
28.01.2020, 02:40

команда sed

uptime| sed '/users/s/users/user/g'

19 :10 :14 вверх 1 мин, 2 пользователя, средняя нагрузка :0,42, 0,19, 0,07

авк

uptime| awk '/users/{gsub("users","user",$0);print $0}'
 19:11:19 up 2 min,  2 user,  load average: 0.14, 0.15, 0.06

питон

!/usr/bin/python
import subprocess
cmd="uptime"
import re

k=subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True).communicate()[0].strip().split('\n')
#print k
for i in k:
    l=re.sub("users","user",i)
    print l
0
28.01.2020, 02:40

Теги

Похожие вопросы