AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-36440

somethingSomething's questions

Martin Hope
somethingSomething
Asked: 2019-06-30 04:56:38 +0800 CST

交互式 shell 中的会话与脚本中的进程

  • 4

如果我在脚本中运行此命令,它不会产生输出,除了来自以下的标头ps:

 # Taken from Advanced Bash Usage on youtube:

 echo "$(echo "$(echo "$(echo "$(ps wwf -s $$)")")")"

这是输出:

$./testing.bash
  PID TTY      STAT   TIME COMMAND

但在这里它在产生预期输出的终端中运行:

$echo "$(echo "$(echo "$(echo "$(ps wwf -s $$)")")")"
  PID TTY      STAT   TIME COMMAND
18289 pts/4    Ss+    0:00 /bin/bash
17917 pts/4    S+     0:00  \_ /bin/bash
17918 pts/4    S+     0:00      \_ /bin/bash
17919 pts/4    S+     0:00          \_ /bin/bash
17920 pts/4    S+     0:00              \_ /bin/bash
17921 pts/4    R+     0:00                  \_ ps wwf -s 18289

问题:

你能解释一下区别并告诉我正确的方法吗?

我已经尝试了很多东西并在 google 上搜索了 4 个小时,如果您需要我可以列出我尝试过的内容,但我认为这与这里无关。

$echo $SHELL
/bin/bash

和:

$head -1 testing.bash 
#!/bin/bash
bash shell-script
  • 1 个回答
  • 1175 Views
Martin Hope
somethingSomething
Asked: 2019-06-08 03:12:32 +0800 CST

Debian:以下软件包已被保留.... odbcinst AND odbcinst1debian2

  • 2

问题:

我有这两个包裹held back for weeks now,我无法摆脱它们,

The following packages have been kept back:
  odbcinst odbcinst1debian2

看这里:

[10:53:34][kristjan] ~ ~↓↓$↓↓ sudo apt upgrade --with-new-pkgs
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  odbcinst odbcinst1debian2
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
[10:53:44][kristjan] ~ ~↓↓$↓↓ sudo apt-get upgrade --with-new-pkgs
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  odbcinst odbcinst1debian2
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
[10:53:53][kristjan] ~ ~↓↓$↓↓ sudo apt dist-upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  odbcinst odbcinst1debian2
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
[10:55:08][kristjan] ~ ~↓↓$↓↓ sudo apt install odbcinst odbcinst1debian2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  amarok-common amarok-utils apper apper-data avogadro-data cdparanoia cdrdao clamz debconf-kde-data debconf-kde-helper dvd+rw-tools espeak-ng-data festival festival-freebsoft-utils festlex-cmu festlex-poslex festvox-kallpc16k
  gnome-orca gnugo growisofs icoutils k3b-data kalzium-data kate-data kde-baseapps-data kde-runtime-data kdegames-card-data kdegames-mahjongg-data ktorrent-data ktouch-data kwrite libakonadiprotocolinternals1 libatk-adaptor
  libavogadro1 libdebconf-kde1 libdiscid0 libdmtx0a libdotconf0 libespeak-ng1 libestools2.4 libgadu3 libgpgme++2v5 libgpod-common libgpod4 libgpod4-nogtk libjs-mootools libkactivities6 libkcalcore4 libkcmutils4 libkcompactdisc4
  libkdeclarative5 libkdesu5 libkdnssd4 libkexiv2-11 libkexiv2-data libkidletime4 libkimap4 libkjsapi4 libkjsembed4 libkldap4 libkmime4 libkntlm4 libkonq5-templates libkpty4 libkresources4 libkrosscore4 libksane0 libkunitconversion4
  liblastfm1 liblimba0 libloudmouth1-0 libmariadbd18 libmeanwhile1 libmediastreamer-base3 libmusicbrainz5cc2v5 libmygpo-qt1 libntrack-qt4-1 libntrack0 libopenbabel4v5 libortp9 libotr5 libpcaudio0 libperl4-corelibs-perl libphonon4
  libpolkit-qt-1-1 libpoppler-qt4-4 libprison0 libqaccessibilityclient0 libqca2 libqca2-plugin-ossl libqca2-plugins libqimageblitz4 libqjson0 libqmobipocket1 libqrencode3 libqtassistantclient4 libqtscript4-core libqtscript4-gui
  libqtscript4-network libqtscript4-sql libqtscript4-uitools libqtscript4-xml libqtwebkit4 libsgutils2-2 libsolid4 libsonic0 libspeechd2 libtag-extras1 libthreadweaver4 ntrack-module-libnl-0 oxygen-icon-theme palapeli-data phonon
  phonon-backend-gstreamer phonon-backend-gstreamer-common polkit-kde-1 python-attr python-avogadro python-click python-colorama python-constantly python-incremental python-openssl python-pam python-pyasn1-modules python-qt4
  python-qt4-sql python-serial python-service-identity python-sip python-twisted-bin python-twisted-core python-zope.interface python3-brlapi python3-louis python3-pyatspi python3-speechd qhull-bin qtdeclarative4-kqtquickcharts-1
  sound-icons sound-theme-freedesktop speech-dispatcher speech-dispatcher-audio-plugins speech-dispatcher-espeak-ng speech-dispatcher-festival vcdimager xbrlapi
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  amarok dolphin4 jovie juk k3b k3b-i18n kaccessible kajongg kalzium katepart kcachegrind kchmviewer kde-baseapps kde-baseapps-bin kde-config-cddb kde-full kde-games-core-declarative kde-plasma-desktop kde-runtime kde-standard
  kdeaccessibility kdeadmin kdeedu kdegames kdegraphics kdegraphics-mobipocket kdelibs-bin kdelibs5-plugins kdemultimedia kdenetwork kdepasswd kdepimlibs-kio-plugins kdesdk kdesdk-kio-plugins kdesdk-misc kdesudo kdeutils kdewebdev
  kdoctools kfilereplace kfind kget kgoldrunner kgpg kigo kimagemapeditor kio-audiocd kio-mtp klinkstatus kmag kmousetool kmouth kmtrace kolf kommander konq-plugins konqueror konqueror-nsplugins konquest kopete kpart-webkit kpartloader
  kppp kremotecontrol kreversi ksaneplugin kscd ksirk ksnakeduel kspaceduel ksudoku ktorrent ktouch kubrick kuiviewer kuser libakonadi-contact4 libakonadi-kde4 libakonadi-kmime4 libiodbc2 libk3b6 libk3b6-extracodecs libkabc4
  libkatepartinterfaces4 libkcddb4 libkde3support4 libkdegames6abi1 libkdegamesprivate1abi1 libkdewebkit5 libkemoticons4 libkfile4 libkhtml5 libkio5 libkmediaplayer4 libknewstuff2-4 libknewstuff3-4 libknotifyconfig4 libkonq-common
  libkonq5abi1 libkonqsidebarplugin4a libkopete4 libkparts4 libkpimidentities4 libkpimtextedit4 libkpimutils4 libkprintutils4 libkrossui4 libktexteditor4 libktorrent-l10n libktorrent5 libkxmlrpcclient4 libmailtransport4 libnepomuk4
  libnepomukquery4a libnepomukutils4 libokularcore7 libplasma3 libreoffice-kde libsoprano4 libsyndication4 lskat okular palapeli plasma-scriptengine-javascript python-kde4 soprano-daemon svgpart sweeper task-kde-desktop
The following packages will be upgraded:
  odbcinst odbcinst1debian2
2 upgraded, 0 newly installed, 129 to remove and 0 not upgraded.
Need to get 147 kB of archives.
After this operation, 231 MB disk space will be freed.
Do you want to continue? [Y/n]n

我试过的:

根据debian-administration.org上的一篇文章,

If the dependencies have changed on one of the packages you have installed so that a new package must be installed to perform the upgrade then that will be listed as "kept-back".

谨慎的解决方案1:

根据Pablo 的回答,您可以运行sudo apt-get --with-new-pkgs upgrade,它会安装保留的软件包。

这样做的好处是不会将保留的软件包标记为“手动安装”,这可能会迫使更多的用户干预(见评论)。

如果 Pablo 的解决方案适合您,请点赞。如果没有,请评论出了什么问题。

谨慎的解决方案2:

谨慎的解决方案是运行sudo apt-get install <list of packages kept back>。在大多数情况下,这将为保留的软件包提供成功升级所需的内容。

激进的解决方案:

更激进的解决方案是 run sudo apt-get dist-upgrade,这将强制安装这些新的依赖项。

但dist-upgrade可能非常危险。与升级不同,它可能会删除软件包以解决复杂的依赖情况。与您不同,APT 并不总是足够聪明,无法知道这些添加和删除是否会造成严重破坏。

因此,如果您发现自己处于“谨慎解决方案”不起作用的地方,dist-upgrade可能会起作用......但是您最好了解更多有关 APT 的知识并通过安装和删除“手动”解决依赖问题根据具体情况打包。

把它想象成修理汽车......如果你有时间并且可以用扳手方便,通过阅读和自己修理你会得到一些安心。如果你觉得幸运的话,你可以把你的车交给你的表妹dist-upgrade,希望她知道她的事情。

我也试过:

[11:06:55][kristjan] ~ ~↓↓$↓↓ sudo aptitude safe-upgrade
Resolving dependencies...                
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.

问题:

如何解决这个问题并摆脱这个恼人的警告?

apt policy odbcinst odbcinst1debian2节目

odbcinst:
  Installed: 2.3.4-1
  Candidate: 2.3.7
  Version table:
     2.3.7 500
        500 https://packages.microsoft.com/debian/9/prod stretch/main amd64 Packages
 *** 2.3.4-1 500
        500 http://deb.debian.org/debian stable/main amd64 Packages
        100 /var/lib/dpkg/status
odbcinst1debian2:
  Installed: 2.3.4-1
  Candidate: 2.3.7
  Version table:
     2.3.7 500
        500 https://packages.microsoft.com/debian/9/prod stretch/main amd64 Packages
 *** 2.3.4-1 500
        500 http://deb.debian.org/debian stable/main amd64 Packages
        100 /var/lib/dpkg/status
debian apt
  • 1 个回答
  • 2094 Views
Martin Hope
somethingSomething
Asked: 2019-06-06 09:13:00 +0800 CST

如何列出所有已安装的扩展名为 .rpm 的软件包。Fedora、Centos、红帽

  • 1

如何获取所有已安装.rpm扩展包的列表?

我正在 Fedora 28 上进行测试。

fedora package-management
  • 2 个回答
  • 525 Views
Martin Hope
somethingSomething
Asked: 2019-05-09 03:07:43 +0800 CST

如何修复“.service:启动请求重复太快”。关于定制服务?

  • 8

我正在学习如何使用 systemd 创建服务。我收到此错误:

.service: Start request repeated too quickly.

我不能再启动服务了;昨天还在工作。我究竟做错了什么?

(root@Kundrum)-(11:03:19)-(~)
$nano /lib/systemd/system/swatchWATCH.service
 1 [Unit]
 2 Description=Monitor Logfiles and send Mail reports
 3 After=syslog.target network.target
 4
 5 [Service]
 6 Type=simple
 7 ExecStart=/usr/bin/swatch --config-file=/home/kristjan/.swatchrc --input-record-separator="\n \n " --tail-file=/var/log/snort/alert --daemon
 8 Restart=on-failure
 9 StartLimitInterval=3
10 StartLimitBurst=100
11
12 [Install]
13 WantedBy=multi-user.target

StartLimitIntervalStartLimitBurst我在尝试修复它后添加了。

我的系统是 Debian 9.8 拉伸所有更新。

debian systemd
  • 3 个回答
  • 27645 Views
Martin Hope
somethingSomething
Asked: 2019-04-20 02:31:32 +0800 CST

当我想更新我的系统时,apt 总是被锁定在其他职责中

  • 3

很多时候,当我想要update我的一个系统时,apt被其他进程“锁定”。它可以在同一天发生不止一次。我必须运行这个命令和kill顶级进程才能apt返回,但我不应该有这个问题,我以前从来没有过。

当我这样做时,apt update我得到了这个:

root ~ # apt update
Reading package lists... Done
E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/

我的系统是 Debian stretch 9.8,我安装了所有更新。我使用 KDE Plasma 桌面。

root ~ # ps aux | grep apt
_apt     25783  9.0  0.1  64300 24956 ?        S    10:12   0:59 /usr/lib/apt/methods/http
_apt     25784  8.9  0.1  64300 25032 ?        S    10:12   0:59 /usr/lib/apt/methods/http
_apt     25785  8.9  0.2 206296 35636 ?        S    10:12   0:59 /usr/lib/apt/methods/https
_apt     25786  9.0  0.2 206300 35532 ?        S    10:12   0:59 /usr/lib/apt/methods/https
_apt     25787  9.0  0.1  64300 25012 ?        S    10:12   0:59 /usr/lib/apt/methods/http
_apt     25788  8.9  0.1  64300 25008 ?        S    10:12   0:58 /usr/lib/apt/methods/http
_apt     25789  9.1  0.1  64300 25192 ?        S    10:12   0:59 /usr/lib/apt/methods/http
_apt     25790  9.1  0.1  64300 24984 ?        S    10:12   0:59 /usr/lib/apt/methods/http
_apt     25817  4.8  0.1  56876 21644 ?        S    10:14   0:28 /usr/lib/apt/methods/gpgv
_apt     25818  4.8  0.2 206296 35568 ?        S    10:14   0:28 /usr/lib/apt/methods/https
_apt     25820  4.7  0.2 206304 35636 ?        S    10:14   0:27 /usr/lib/apt/methods/https
_apt     26426  0.0  0.1  56876 19752 ?        S    10:22   0:00 /usr/lib/apt/methods/gpgv
_apt     26427  0.0  0.0   4276  1656 ?        S    10:22   0:00 /bin/sh /usr/bin/apt-key --quiet --readonly verify --status-fd 3 /tmp/apt.sig.LTumm1 /tmp/apt.data.hNgDBV
_apt     26511  104  0.0  38092  8508 ?        R    10:23   0:03 apt-config shell GPGV Apt::Key::gpgvcommand
root     26513  0.0  0.0  12788  1000 pts/1    S+   10:23   0:00 grep apt

问题:

我不明白这意味着什么是 apt 做什么以及如何解决它?

编辑:

pstree -a

root ~ # apt list packagekit
Listing... Done
packagekit/stable,stable,now 1.1.5-2+deb9u1 amd64 [installed,automatic]

root ~ # apt list aptdaemon
Listing... Done
debian apt
  • 2 个回答
  • 3227 Views
Martin Hope
somethingSomething
Asked: 2019-04-20 02:25:31 +0800 CST

让 logwatch 每周只发送一次报告

  • 3

我想减少logwatch在三个系统上发送到我的电子邮件的报告的噪音。

是否可以通过将 logwatch 配置为每周仅发送几天或每周发送一次?

更多相关数据:

logwatch8-is-too-noisy-how-can-i-control-the-noise-level on SERVERFAULT

/usr/share/logwatch/default.conf/logwatch.conf:

########################################################
# This was written and is maintained by:
#    Kirk Bauer <[email protected]>
#
# Please send all comments, suggestions, bug reports,
#    etc, to [email protected].
#
########################################################

# NOTE:
#   All these options are the defaults if you run logwatch with no
#   command-line arguments.  You can override all of these on the
#   command-line.

# You can put comments anywhere you want to.  They are effective for the
# rest of the line.

# this is in the format of <name> = <value>.  Whitespace at the beginning
# and end of the lines is removed.  Whitespace before and after the = sign
# is removed.  Everything is case *insensitive*.

# Yes = True  = On  = 1
# No  = False = Off = 0

# Default Log Directory
# All log-files are assumed to be given relative to this directory.
LogDir = /var/log

# You can override the default temp directory (/tmp) here
TmpDir = /var/cache/logwatch

#Output/Format Options
#By default Logwatch will print to stdout in text with no encoding.
#To make email Default set Output = mail to save to file set Output = file
Output = stdout
#To make Html the default formatting Format = html
Format = text
#To make Base64 [aka uuencode] Encode = base64
Encode = none

# Default person to mail reports to.  Can be a local account or a
# complete email address.  Variable Output should be set to mail, or
# --output mail should be passed on command line to enable mail feature.
MailTo = root
# WHen using option --multiemail, it is possible to specify a different
# email recipient per host processed.  For example, to send the report
# for hostname host1 to [email protected], use:
#Mailto_host1 = [email protected]
# Multiple recipients can be specified by separating them with a space.

# Default person to mail reports from.  Can be a local account or a
# complete email address.
MailFrom = Logwatch

# if set, the results will be saved in <filename> instead of mailed
# or displayed. Be sure to set Output = file also.
#Filename = /tmp/logwatch

# Use archives?  If set to 'Yes', the archives of logfiles
# (i.e. /var/log/messages.1 or /var/log/messages.1.gz) will
# be searched in addition to the /var/log/messages file.
# This usually will not do much if your range is set to just
# 'Yesterday' or 'Today'... it is probably best used with Range = All
# By default this is now set to Yes. To turn off Archives uncomment this.
#Archives = No

# The default time range for the report...
# The current choices are All, Today, Yesterday
Range = Today

# The default detail level for the report.
# This can either be Low, Med, High or a number.
# Low = 0
# Med = 5
# High = 10
Detail = 10


# The 'Service' option expects either the name of a filter
# (in /usr/share/logwatch/scripts/services/*) or 'All'.
# The default service(s) to report on.  This should be left as All for
# most people.
Service = All
# You can also disable certain services (when specifying all)
Service = "-zz-network"     # Prevents execution of zz-network service, which
                            # prints useful network configuration info.
Service = "-zz-sys"         # Prevents execution of zz-sys service, which
                            # prints useful system configuration info.
Service = "-eximstats"      # Prevents execution of eximstats service, which
                            # is a wrapper for the eximstats program.
# If you only cared about FTP messages, you could use these 2 lines
# instead of the above:
#Service = ftpd-messages   # Processes ftpd messages in /var/log/messages
#Service = ftpd-xferlog    # Processes ftpd messages in /var/log/xferlog
# Maybe you only wanted reports on PAM messages, then you would use:
#Service = pam_pwdb        # PAM_pwdb messages - usually quite a bit
#Service = pam             # General PAM messages... usually not many

# You can also choose to use the 'LogFile' option.  This will cause
# logwatch to only analyze that one logfile.. for example:
#LogFile = messages
# will process /var/log/messages.  This will run all the filters that
# process that logfile.  This option is probably not too useful to
# most people.  Setting 'Service' to 'All' above analyzes all LogFiles
# anyways...

#
# By default we assume that all Unix systems have sendmail or a sendmail-like MTA.
# The mailer code prints a header with To: From: and Subject:.
# At this point you can change the mailer to anything that can handle this output
# stream.
# TODO test variables in the mailer string to see if the To/From/Subject can be set
# From here with out breaking anything. This would allow mail/mailx/nail etc..... -mgt
mailer = "/usr/sbin/sendmail -t"

#
# With this option set to a comma separted list of hostnames, only log entries
# for these particular hosts will be processed.  This can allow a log host to
# process only its own logs, or Logwatch can be run once per a set of hosts
# included in the logfiles.
# Example: HostLimit = hosta,hostb,myhost
#
# The default is to report on all log entries, regardless of its source host.
# Note that some logfiles do not include host information and will not be
# influenced by this setting.
#
#HostLimit = myhost

# vi: shiftwidth=3 tabstop=3 et
linux logs
  • 2 个回答
  • 1548 Views
Martin Hope
somethingSomething
Asked: 2019-04-14 15:32:06 +0800 CST

如何让 `trap` 知道 EXIT 是在程序成功完成之后还是由于过早的错误或其他原因

  • 5

问题:

我有一个我一直在编写的 shell 程序,但我不知道如何确保它trap在最后被捕获以进行清理,或者由于某些命令中的错误,它会以任何一种方式进行清理。

这是代码:

################################### Successful exit then this cleanup ###########################################################3

successfulExit()
{
    IFS=$IFS_OLD
    cd "$HOME" || { echo "cd $HOME failed"; exit 155; }
    rm -rf /tmp/svaka || { echo "Failed to remove the install directory!!!!!!!!"; exit 155; }
}
###############################################################################################################################33
####### Catch the program on successful exit and cleanup
trap successfulExit EXIT

问题:

我怎样才能trap只trap EXIT在程序完成时制作?

这是完整的脚本:

debianConfigAwsome.5.3.sh

shell-script exit-status
  • 1 个回答
  • 858 Views
Martin Hope
somethingSomething
Asked: 2019-04-12 01:44:32 +0800 CST

shell 脚本中的“cd”命令何时会失败,我该怎么做才能补救?

  • 1

我有一个上周未能完成的 shell 脚本;这是一个失败的“ cd”命令,如果失败则退出。

该脚本是一个bash用于配置新 Debian 安装的 shell 脚本。这是完整的脚本:debianConfigAswome.sh。该脚本以 root 身份运行,因此它具有对文件系统的完全访问权限。

您能否列出脚本无法成功执行cd命令的所有原因以及如何避免该错误?

shell-script command
  • 1 个回答
  • 4671 Views
Martin Hope
somethingSomething
Asked: 2019-04-09 13:36:09 +0800 CST

apt update 有两个失败的索引文件,我在网上找不到任何关于该做什么的信息

  • 2

我正在更新我的一个系统,但我收到一个错误,我不知道如何修复或问题出在哪里。

这是错误:

E: Failed to fetch http://the.earth.li/debian/dists/stretch-updates/main/binary-i386/Packages  404  Not Found [IP: 46.43.34.31 80]
E: Failed to fetch http://the.earth.li/debian/dists/stretch/main/binary-i386/Packages  404  Not Found [IP: 46.43.34.31 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.

root /home/kristjan # apt update                                                                                                                                                                                                    
Hit:1 http://ftp.debian.org/debian stretch-backports InRelease
Hit:2 http://security.debian.org/debian-security stretch/updates InRelease                                                                                                                                                     
Hit:3 http://download.virtualbox.org/virtualbox/debian stretch InRelease                       
Hit:4 https://download.mono-project.com/repo/debian stable-stretch InRelease                          
Hit:5 http://www.deb-multimedia.org stretch InRelease                                                 
Hit:6 http://repo.steampowered.com/steam precise InRelease                                            
Hit:7 https://deb.torproject.org/torproject.org stretch InRelease
Ign:8 http://the.earth.li/debian stretch InRelease 
Get:9 http://the.earth.li/debian stretch-updates InRelease [91.0 kB]
Get:10 http://the.earth.li/debian stretch Release [118 kB]    
Get:11 http://the.earth.li/debian stretch-updates/main Sources.diff/Index [8,608 B]
Get:12 http://the.earth.li/debian stretch-updates/main i386 Packages.diff/Index [8,608 B]
Get:12 http://the.earth.li/debian stretch-updates/main i386 Packages.diff/Index [8,608 B]
Ign:12 http://the.earth.li/debian stretch-updates/main i386 Packages.diff/Index
Get:15 http://the.earth.li/debian stretch Release.gpg [2,434 B]
Get:16 http://the.earth.li/debian stretch-updates/main Sources 2019-02-21-2009.35.pdiff [10.2 kB]
Get:17 http://the.earth.li/debian stretch-updates/main Sources 2019-03-27-2010.32.pdiff [471 B]
Get:18 http://the.earth.li/debian stretch-updates/main Sources 2019-03-30-2008.27.pdiff [726 B]
Get:19 http://the.earth.li/debian stretch-updates/main amd64 Packages 2019-02-21-2009.35.pdiff [4,149 B]
Get:20 http://the.earth.li/debian stretch-updates/main amd64 Packages 2019-03-27-2010.32.pdiff [531 B]
Get:21 http://the.earth.li/debian stretch-updates/main amd64 Packages 2019-03-30-2008.27.pdiff [1,599 B]
Get:22 http://the.earth.li/debian stretch-updates/main Translation-en 2019-02-21-2009.35.pdiff [5,483 B]
Get:18 http://the.earth.li/debian stretch-updates/main Sources 2019-03-30-2008.27.pdiff [726 B]
Get:22 http://the.earth.li/debian stretch-updates/main Translation-en 2019-02-21-2009.35.pdiff [5,483 B]
Get:21 http://the.earth.li/debian stretch-updates/main amd64 Packages 2019-03-30-2008.27.pdiff [1,599 B]
Ign:23 http://the.earth.li/debian stretch-updates/main i386 Packages                                     
Get:24 http://the.earth.li/debian stretch/non-free Sources [79.4 kB]
Get:25 http://the.earth.li/debian stretch/main Sources [6,746 kB]
Get:26 http://the.earth.li/debian stretch/main i386 Packages [7,064 kB]
Get:26 http://the.earth.li/debian stretch/main i386 Packages [7,064 kB]
Get:26 http://the.earth.li/debian stretch/main i386 Packages [7,064 kB]
Get:26 http://the.earth.li/debian stretch/main i386 Packages [7,064 kB]
Ign:26 http://the.earth.li/debian stretch/main i386 Packages
Ign:31 http://the.earth.li/debian stretch/non-free i386 Packages
Ign:23 http://the.earth.li/debian stretch-updates/main i386 Packages
Ign:26 http://the.earth.li/debian stretch/main i386 Packages
Ign:31 http://the.earth.li/debian stretch/non-free i386 Packages
Err:23 http://the.earth.li/debian stretch-updates/main i386 Packages
  404  Not Found [IP: 46.43.34.31 80]
Ign:26 http://the.earth.li/debian stretch/main i386 Packages
Ign:31 http://the.earth.li/debian stretch/non-free i386 Packages
Err:26 http://the.earth.li/debian stretch/main i386 Packages
  404  Not Found [IP: 46.43.34.31 80]
Ign:31 http://the.earth.li/debian stretch/non-free i386 Packages
Fetched 235 kB in 1s (125 kB/s)
Reading package lists... Done
E: Failed to fetch http://the.earth.li/debian/dists/stretch-updates/main/binary-i386/Packages  404  Not Found [IP: 46.43.34.31 80]
E: Failed to fetch http://the.earth.li/debian/dists/stretch/main/binary-i386/Packages  404  Not Found [IP: 46.43.34.31 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.

这是系统:

root /home/kristjan # cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

这是来源列表:

root /home/kristjan # cat /etc/apt/sources.list
# 
#deb cdrom:[Debian GNU/Linux 9.4.0 _S
#deb cdrom:[Debian GNU/Linux 9.4.0 _S

deb http://www.deb-multimedia.org stretch main non-free

deb http://the.earth.li/debian/ stretch main non-free
deb-src http://the.earth.li/debian/ stretch main non-free

deb http://security.debian.org/debian-security stretch/updates main contrib non-free
deb-src http://security.debian.org/debian-security stretch/updates main contrib non-free

# stretch-updates, previously known as 'volatile'
deb http://the.earth.li/debian/ stretch-updates main contrib non-free
deb-src http://the.earth.li/debian/ stretch-updates main contrib non-free

# Virtualbox Oracle
deb http://download.virtualbox.org/virtualbox/debian stretch contrib


#Tor###########################97
deb https://deb.torproject.org/torproject.org stretch main
deb-src https://deb.torproject.org/torproject.org stretch main
# For the stable version.
#deb tor://sdscoq7snqtznauu.onion/torproject.org stretch main


########################### Backports testingittt
#deb http://ftp.debian.org/debian stretch-backports main

这里有什么问题,我该如何解决?

更新:

我有两台服务器都运行 Debian Stretch 9.9,并且使用相同的 debian 服务器进行软件包和更新,但我只能更新其中一个,这个给我这个错误:

~↓↓$↓↓ apt update
Hit:1 http://www.deb-multimedia.org stretch InRelease
Ign:2 http://the.earth.li/debian stretch InRelease                                                                                                        
Hit:3 http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic InRelease                                                                                 
Get:4 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]                                                                      
Hit:6 http://download.virtualbox.org/virtualbox/debian stretch InRelease                                                                                  
Hit:7 http://ftp.debian.org/debian stretch-backports InRelease                                                                                            
Get:5 http://the.earth.li/debian stretch-updates InRelease [91.0 kB]                                                                                      
Hit:9 http://repo.mysql.com/apt/debian stretch InRelease                                                                                    
Hit:10 https://packages.microsoft.com/debian/9/prod stretch InRelease                                      
Hit:11 https://packages.microsoft.com/repos/vscode stable InRelease                  
Get:8 http://the.earth.li/debian stretch Release [118 kB]                
Hit:12 https://deb.torproject.org/torproject.org stretch InRelease                                     
Get:13 http://security.debian.org/debian-security stretch/updates/main Sources [205 kB]                 
Get:14 http://the.earth.li/debian stretch Release.gpg [2,434 B]                                                       
Get:15 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [492 kB]                                       
Get:16 http://the.earth.li/debian stretch-updates/main Sources [13.1 kB]            
Get:17 http://the.earth.li/debian stretch-updates/main amd64 Packages [27.2 kB]                            
Get:18 http://the.earth.li/debian stretch-updates/main i386 Packages [27.2 kB]                             
Get:18 http://the.earth.li/debian stretch-updates/main i386 Packages [27.2 kB]                                               
Hit:21 http://repo.steampowered.com/steam precise InRelease                                                                             
Ign:18 http://the.earth.li/debian stretch-updates/main i386 Packages                                       
Ign:22 http://the.earth.li/debian stretch-updates/main i386 Contents (deb)          
Get:23 http://security.debian.org/debian-security stretch/updates/main i386 Packages [494 kB]
Ign:18 http://the.earth.li/debian stretch-updates/main i386 Packages                                         
Hit:24 https://download.mono-project.com/repo/debian stable-stretch InRelease                                
Ign:25 https://apt.jenslody.de/stable stretch InRelease                                                       
Err:22 http://the.earth.li/debian stretch-updates/main i386 Contents (deb)          
  404  Not Found [IP: 46.43.34.31 80]
Get:18 http://the.earth.li/debian stretch-updates/main i386 Packages [169 kB]       
Get:18 http://the.earth.li/debian stretch-updates/main i386 Packages [169 kB]           
Hit:28 https://apt.jenslody.de/stable stretch Release                                    
Get:18 http://the.earth.li/debian stretch-updates/main i386 Packages [169 kB]
Get:18 http://the.earth.li/debian stretch-updates/main i386 Packages [169 kB]
Get:18 http://the.earth.li/debian stretch-updates/main i386 Packages [169 kB]
Get:18 http://the.earth.li/debian stretch-updates/main i386 Packages [169 kB]
Get:18 http://the.earth.li/debian stretch-updates/main i386 Packages [169 kB]
Get:18 http://the.earth.li/debian stretch-updates/main i386 Packages [169 kB]
Ign:18 http://the.earth.li/debian stretch-updates/main i386 Packages
Ign:36 http://the.earth.li/debian stretch/main i386 Packages
Get:37 http://the.earth.li/debian stretch/main i386 Contents (deb) [31.3 MB]
Get:38 http://the.earth.li/debian stretch/main amd64 Contents (deb) [31.4 MB]                                                                             
Get:39 http://the.earth.li/debian stretch/non-free amd64 Packages [78.3 kB]                                                                               
Ign:40 http://the.earth.li/debian stretch/non-free i386 Packages                                                                                          
Get:41 http://the.earth.li/debian stretch/non-free Translation-en [80.3 kB]                                                                               
Get:42 http://the.earth.li/debian stretch/non-free amd64 DEP-11 Metadata [7,180 B]                                                                        
Get:43 http://the.earth.li/debian stretch/non-free DEP-11 64x64 Icons [30.0 kB]                                                                           
Get:44 http://the.earth.li/debian stretch/non-free DEP-11 128x128 Icons [85.2 kB]                                                                         
Get:45 http://the.earth.li/debian stretch/non-free amd64 Contents (deb) [809 kB]                                                                          
Get:46 http://the.earth.li/debian stretch/non-free i386 Contents (deb) [750 kB]                                                                           
Ign:36 http://the.earth.li/debian stretch/main i386 Packages                                                                                              
Ign:40 http://the.earth.li/debian stretch/non-free i386 Packages                                                                                          
Ign:36 http://the.earth.li/debian stretch/main i386 Packages                                                                                              
Ign:40 http://the.earth.li/debian stretch/non-free i386 Packages                                                                                          
Err:36 http://the.earth.li/debian stretch/main i386 Packages                                                                                              
  404  Not Found [IP: 46.43.34.31 80]
Ign:40 http://the.earth.li/debian stretch/non-free i386 Packages                                                                                          
Fetched 44.7 MB in 13s (3,223 kB/s)                                                                                                                       
Reading package lists... Done
E: Failed to fetch http://the.earth.li/debian/dists/stretch-updates/main/Contents-i386  404  Not Found [IP: 46.43.34.31 80]
E: Failed to fetch http://the.earth.li/debian/dists/stretch/main/binary-i386/Packages  404  Not Found [IP: 46.43.34.31 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.

以下是其他list文件,仅供参考:

~↓↓$↓↓ ls -asil /etc/apt/sources.list.d/
total 36
1175229 4 drwxr-xr-x 2 root root 4096 May 18 09:52 .
1175056 4 drwxr-xr-x 6 root root 4096 May 23 01:54 ..
1178126 4 -rw-r--r-- 1 root root   67 May  2 08:18 linuxuprising-java.list
1178021 4 -rw-r--r-- 1 root root   75 Jan 17  2018 microsoft-prod.list
1177218 4 -rw-r--r-- 1 root root   70 Jul 12  2018 mono-official-stable.list
1176353 4 -rw-r--r-- 1 root root  712 May 13 06:23 mysql.list
1178155 4 -rw-r--r-- 1 root root  148 Jul 24  2018 steam.list
1178030 4 -rw-r--r-- 1 root root   64 Jul 21  2018 stretch-backports.list
1176782 4 -rw-r--r-- 1 root root   73 May 18 09:42 vscode.list

这是sources.list在另一台服务器上:

deb http://www.deb-multimedia.org stretch main non-free

deb http://the.earth.li/debian/ stretch main non-free
deb-src http://the.earth.li/debian/ stretch main non-free

deb http://security.debian.org/debian-security stretch/updates main contrib non-free
deb-src http://security.debian.org/debian-security stretch/updates main contrib non-free

# stretch-updates, previously known as 'volatile'
deb http://the.earth.li/debian/ stretch-updates main contrib non-free
deb-src http://the.earth.li/debian/ stretch-updates main contrib non-free

# Virtualbox Oracle
deb http://download.virtualbox.org/virtualbox/debian stretch contrib
linux debian
  • 1 个回答
  • 1309 Views
Martin Hope
somethingSomething
Asked: 2018-11-20 22:54:06 +0800 CST

为什么我在网上找不到关于此命令的任何内容?`statftime`

  • -2

问题:

我正在bash从书中学习(Linux Shell Scripting with Bash,Ken​​ O. Burch),我现在关注的这本书正在使用这个命令:

/usr/bin/statftime

但是我找不到适用于我的 Linux 的这个命令

我正在使用 Debian 9.0 stretch

问题:

你能告诉我这个命令吗?是否可以在 Debian 上安装它以及如何在 Debian 上安装它?

编辑:

bash这本书是我读过的最好的书之一(Linux Shell Scripting with Bash,Ken​​ O. Burch)(@Gilles)所以这可能不是一个技巧,我将在下面发布代码:

这是代码:

#!/bin/bash -x
#
# polling.sh: a daemon using polling to check for new files

shopt -s -o nounset

declare -rx SCRIPT=${0##*/}
declare -rx INCOMING_FTP_DIR="/home/ftp/ftp_incoming"
declare -rx PROCESSING_DIR="/home/ftp/processing"
declare -rx statftime="/usr/local/bin/statftime"
declare FILE=""
declare FILES=""
declare NEW_FILE=""

printf "$SCRIPT started at %s\n" "`date`"

# Sanity checks
if [[ ! -d /home/ftp/ftp_incoming ]] || [[ ! -d /home/ftp/processing ]]
then
    mkdir -p /home/ftp/ftp_incoming
    mkdir -p /home/ftp/processing
    if [ "$?" -ne 0 ]
    then
        echo "You are a idiot"
    else
        echo "You succeded!"
    fi
fi
if test ! -r "$INCOMING_FTP_DIR"
then
    printf "%s\n" "$SCRIPT:$LINENO: unable to read the incoming directory --aborted" >&1
    exit 1
fi
if test ! -r "$PROCESSING_DIR"
then
    printf "%s\n" "$SCRIPT:$LINENO: unable to read the incoming directory --aborted" >&1
    exit 1
fi
if test ! -r "$statftime"
then
    printf "%s\n" "$SCRIPT:$LINENO: unable to find or execute $statftime --aborted" >&1
    exit 1
fi

# Poll for new FTP files

cd $INCOMING_FTP_DIR
while true
do
    #check for new files more than 30 minutes unchanged
    FILES=`find . -type f -mmin +30 -print`

    # If new files exist, move them to the processing directory

    if [ ! -z "$FILES" ]
    then
        printf "$SCRIPT: new files have arrived at %s\n" "`date`"
        printf "%s\n" "$FILES" |
        {
            while read FILE
            do
                # Remove leading "./"
                FILE=${FILE##*/}
                # Rename the file with the current time
                NEW_FILE=`$statftime -f "%_L%_a_%T.dat" "$FILE"`
                if [ -z "$NEW_FILE" ]
                then
                    printf "%s\n" "$SCRIPT:$LINENO: statftime failed to create a new filename--skipping"
                else
                    # Move the file to the processing directory
                    printf "%s\n" "$SCRIPT: moved $FILE to $PROCESSING_DIR/$NEW_FILE"
                    mv "$FILE" "$PROCESSING_DIR/$NEW_FILE"
                fi
            done
        }
    fi
    sleep 30
done


printf "$SCRIPT finished unexpectedly at %s\n" "`date`"
exit 1

以下是有关命令的一些信息:

搜索

地点

bash shell-script
  • 1 个回答
  • 90 Views
Martin Hope
somethingSomething
Asked: 2018-10-19 05:19:24 +0800 CST

如何在安装程序以在 bash 程序中使用时抑制来自程序的消息?[复制]

  • 7
这个问题在这里已经有了答案:
没有 debconf 提示的 apt-get install (1 个回答)
4年前关闭。

问题:

我有一个用 bash 编写的程序,它可以做很多事情,比如在系统上安装新软件。

它安装的其中一个程序会出现一条奢侈的消息,您可以在其中获得有关使用情况和配置文件的一些信息,以及如果您不编辑配置文件会做什么。

然后等待用户输入。

此消息是dialogGUI 中的一种消息:

在此处输入图像描述

显示此消息的程序是portsentry,系统是 Debian Stretch。

问题:

如何禁止显示此消息,以便我的程序和用户之间没有通信?

debian shell-script
  • 1 个回答
  • 390 Views
Martin Hope
somethingSomething
Asked: 2018-10-19 01:34:30 +0800 CST

你能帮我解释一下这个 bash 代码中的这三件事吗?

  • 10

function我的文件中有一个.bashrc。我知道它的作用,它增加了 X 多个目录cd

这里是:

up()
{
    local d=""
    limit=$1
    for ((i=1 ; i <= limit ; i++))
      do
        d=$d/..
      done
    d=$(echo $d | sed 's/^\///')
    if [ -z "$d" ]; then
      d=..
    fi
    cd $d
}

但是你能帮我解释一下这三件事吗?

  1. d=$d/..
  2. sed 's/^\///'
  3. d=..

为什么不这样做:

up()
{
    limit=$1

    for ((i=1 ; i <= limit ; i++))
    do
        cd ..
    done
}

用法:

<<<>>>~$ up 3
<<<>>>/$
shell sed
  • 2 个回答
  • 2115 Views
Martin Hope
somethingSomething
Asked: 2018-10-18 22:06:33 +0800 CST

在 bash/shell 编程中,python 中是否有类似或类似“通过”的东西?

  • 1

我有时需要在我的 bash 脚本中使用类似passPython 的命令。

喜欢:

if grep something
then
    pass
else
    code
fi

在 Python 中,你有:

>>> for element in a:
...     if not element:
...         pass
...     print element

问题:

我总是使用continue,但它给出了一个错误,它应该只在for,while或until循环中使用。

在这种情况下你会怎么做?

linux bash
  • 2 个回答
  • 3466 Views
Martin Hope
somethingSomething
Asked: 2018-10-18 20:38:28 +0800 CST

$@ 变量不在 for 循环中工作,试图遍历用户列表

  • 1

问题:

我无法让$@变量在 for 循环中执行我想要的操作,循环仅在循环时将一个名称发送到文件中,它应该循环遍历所有参数并将它们各自写入文件USERS.txt中。

这是文件:

something78
something79
something7
dagny
oli
bjarni
toti
stefan_hlynur
jessie

这是测试代码:

#!/bin/bash

prepare_USERS()
{
    /usr/bin/awk -F: '$3 >= 1000 { print $1 }' /etc/passwd > USERS.txt
    /bin/chmod 777 USERS.txt
    echo "$@"
    for user in "$@"
    do
        echo $user
        echo "$user" >> USERS.txt || echo "writing to USERS.txt failed"; exit 127
    done
}

prepare_USERS "$@"

#for user in "$@"
#do
#    echo "$user" >> USERS.txt
#done

for user in USERS.txt
do
    printf "%s" $user
done

以下是我通过的论点:

./somethingDELETEme.sh jessie henry allison jason

当前输出:

$./somethingDELETEme.sh jessie henry allison jason
jessie henry allison jason
jessie

预期输出:

循环遍历参数列表中的所有名称并将其写入文件USERS.txt。

问题:

我以前用过这个变量($@),从来没有遇到过这个问题。

为什么循环没有遍历参数列表 ( $@) 中的所有名称,以及如何正确编码?

这是真正的代码:

prepare_USERS()
{
    checkIfUser
    /usr/bin/awk -F: '$3 >= 1000 { print $1 }' /etc/passwd > "$CURRENTDIR"/USERS.txt

    /bin/chmod 777 "CURRENTDIR"/USERS.txt
    for user in "$@"
    do
        echo "$user" >> "CURRENTDIR"/USERS.txt || echo "writing to USERS.txt failed"; exit 127
    done
}
bash shell-script
  • 1 个回答
  • 366 Views
Martin Hope
somethingSomething
Asked: 2018-10-16 17:57:32 +0800 CST

检查是否在脚本中的系统上设置了 iptables [重复]

  • 1
这个问题在这里已经有了答案:
'>' 和 '-gt' 的区别 1 个回答
4年前关闭。

我正在用 bash 编写脚本,我需要检查是否设置了 iptables ......我有这个:

if [ `iptables-save | grep '^\-' | wc -l` > 0 ]
then
    echo "Iptables already set, skipping..........!"
else
    Here the iptables get set

但它没有按预期工作......

问题:

我做到了iptables-save,它创造了这个:

$iptables-save
# Generated by iptables-save v1.6.0 on Tue Oct 16 02:48:41 2018
*filter
:INPUT ACCEPT [2:266]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [2:116]
COMMIT
# Completed on Tue Oct 16 02:48:41 2018

因此,如果我运行测试,它会发现它们已经设置好了......就像这里:

(root@notemDEB78)-(03:12:20)-(/home/something78/Bash_Programming_2018)
$s.sh
Iptables already set....skipping!!!!!
(root@notemDEB78)-(03:12:25)-(/home/something78/Bash_Programming_2018)
$iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination 

(root@notemDEB78)-(03:16:41)-(/home/something78/Bash_Programming_2018)
$iptables-save | grep '^\-' | wc -l
0

问题:

  • 为什么它总是发现 iptables 显然没有设置
  • 你有更好/工作的方法来检查是否iptables已设置....我的系统是Debian 9

    bash -version GNU bash,版本 4.4.12(1)-release (x86_64-pc-linux-gnu) 版权所有 (C) 2016 Free Software Foundation, Inc. 许可证 GPLv3+:GNU GPL 版本 3 或更高版本http://gnu。 org/licenses/gpl.html

至于可能的重复:

这个问题还询问是否有人有更好的方法来检查是否为 bash 中的脚本设置了 iptables....

编辑:

通过设置,我的意思是 iptables 已设置如下:

if [[ `iptables-save | grep '^\-' | wc -l` > 0 ]]
    then
        echo "Iptables already set....skipping!!!!!"
    else
        if [ "$PORT" = "" ]
        then
            echo "Port not set for iptables exiting"
            echo -n "Setting port now, insert portnumber: "
            read port
            PORT=$port
        fi
        if [ ! -f /etc/iptables.test.rules ]
        then
            touch /etc/iptables.test.rules
        else
            cat /dev/null > /etc/iptables.test.rules
        fi

        cat << EOT >> /etc/iptables.test.rules
        *filter

        # Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
        -A INPUT -i lo -j ACCEPT
        -A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT

        # Accepts all established inOAUTH_TOKEN=d6637f7ccf109a0171a2f55d21b6ca43ff053616bound connections
        -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

        # Allows all outbound traffic
        # You could modify this to only allow certain traffic
        -A OUTPUT -j ACCEPT

        # Allows HTTP and HTTPS connections from anywhere (the normal ports for websites)
        -A INPUT -p tcp --dport 80 -j ACCEPT
        -A INPUT -p tcp --dport 443 -j ACCEPT

        # Allows SSH connections
        # The --dport number is the same as in /etc/ssh/sshd_config
        -A INPUT -p tcp -m state --state NEW --dport $PORT -j ACCEPT

        # Now you should read up on iptables rules and consider whether ssh access
        # for everyone is really desired. Most likely you will only allow access from certain IPs.

        # Allow ping
        #  note that blocking other types of icmp packets is considered a bad idea by some
        #  remove -m icmp --icmp-type 8 from this line to allow all kinds of icmp:
        #  https://security.stackexchange.com/questions/22711
        -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT

        # log iptables denied calls (access via dmesg command)
        -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7

        # Reject all other inbound - default deny unless explicitly allowed policy:
        -A INPUT -j REJECT
        -A FORWARD -j REJECT

        COMMIT
EOT
        sed "s/^[ \t]*//" -i /etc/iptables.test.rules ## remove tabs and spaces
        /sbin/iptables-restore < /etc/iptables.test.rules || echo "iptables-restore failed"; exit 127
        /sbin/iptables-save > /etc/iptables.up.rules || echo "iptables-save failed"; exit 127
        printf "#!/bin/bash\n/sbin/iptables-restore < /etc/iptables.up.rules" > /etc/network/if-pre-up.d/iptables ## create a script to run iptables on startup
        chmod +x /etc/network/if-pre-up.d/iptables || echo "cmod +x failed"; exit 127
    fi
bash shell-script
  • 2 个回答
  • 2653 Views
Martin Hope
somethingSomething
Asked: 2018-10-12 20:14:11 +0800 CST

对 rm 和 ls 使用正则表达式

  • 0

问题:

这里发生了什么,我该如何解决?

问题:

当我做:

$ls | grep -P "file[1-9]{3}.txt|file[1-9]{2}.txt"

我得到:

file11.txt
file12.txt
file13.txt
file14.txt
file15.txt
file16.txt
file17.txt
file18.txt
file19.txt
file21.txt
file22.txt
file23.txt
file24.txt
file25.txt
file26.txt
file27.txt
file28.txt
file29.txt
etc.

但是当我这样做时:

$ls | grep -P "file[1-9]{3}.txt|file[1-9]{2}.txt" | xargs -d"\n" rm

我得到:

rm: cannot remove ''$'\033''[38;5;253mfile11.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile12.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile13.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile14.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile15.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile16.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile17.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile18.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile19.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile21.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile22.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile23.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile24.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile25.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile26.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile27.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile28.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile29.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile31.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile32.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile33.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile34.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile35.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile36.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile37.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile38.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile39.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile41.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile42.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile43.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile44.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile45.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile46.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile47.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile48.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile49.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile51.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile52.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile53.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile54.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile55.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile56.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile57.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile58.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile59.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile61.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile62.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile63.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile64.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile65.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile66.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile67.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile68.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile69.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile71.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile72.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile73.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile74.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile75.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile76.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile77.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile78.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile79.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile81.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile82.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile83.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile84.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile85.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile86.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile87.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile88.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile89.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile91.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile92.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile93.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile94.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile95.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile96.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile97.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile98.txt'$'\033''[0m': No such file or directory
rm: cannot remove ''$'\033''[38;5;253mfile99.txt'$'\033''[0m': No such file or directory
etc.

期望的结果:

rm 删除所有匹配正则表达式的文件

grep regular-expression
  • 2 个回答
  • 10628 Views
Martin Hope
somethingSomething
Asked: 2018-09-18 10:59:42 +0800 CST

编辑 sshd_config 时,我没有从 sed 获得我想要的输出

  • 0

我正在编写一个程序来设置新的Debian安装,但我无法sed做我想做的事。我想将新用户添加到sshd_configasallowed users

但我明白了:这是我现在得到的结果:

  6
  7 AllowUsers user
  8 AllowUsers something78
  9 AllowUsers something7
 10 AllowUsers something78
 11 AllowUsers something79
 12 AllowUsers something78
 13 AllowUsers something7
 14 AllowUsers something78

它应该在哪里:预期结果是这样的:

     AllowUsers user
     AllowUsers something7
     AllowUsers something78
     AllowUsers something79

这是代码:

setUPsshd()
 4 {
 5     if grep "Port $PORT" /etc/ssh/sshd_config
 6     then
 7         echo "sshd already set, skipping!"
 8     else
 9         #/bin/cp -f "$CURRENTDIR"/sshd_config /etc/ssh/sshd_config
10         sed -i "s/Port 22/Port $PORT/" /etc/ssh/sshd_config
11         for user in `awk -F: '$3 > 1000 { print $1 }' /etc/passwd`
12         do
13             sed -i "/AllowUsers/a AllowUsers $user" /etc/ssh/sshd_config
14         done
15         USERNAME=`awk -F: '$3 == 1000 { print $1 }' /etc/passwd`
16         if ! grep "AllowUsers $USERNAME" /etc/ssh/sshd_config
17         then
18             sed -i "/AllowUsers/a AllowUsers $USERNAME" /etc/ssh/sshd_config
19         fi
20         echo "chmod 644 /etc/ssh/sshd_config"
21         echo "/etc/init.d/ssh restart"
22     fi
23 }

这是调试输出:

+ PORT=22301
+ setUPsshd
+ grep 'Port 22' /etc/ssh/sshd_config
+ /bin/cp -f /tmp/svaka/sshd_config /etc/ssh/sshd_config
+ sed -i 's/Port 22/Port 22301/' /etc/ssh/sshd_config
++ awk -F: '$3 > 1000 { print $1 }' /etc/passwd
+ for user in `awk -F: '$3 > 1000 { print $1 }' /etc/passwd`
+ sed -i '/AllowUsers/a AllowUsers something79' /etc/ssh/sshd_config
+ for user in `awk -F: '$3 > 1000 { print $1 }' /etc/passwd`
+ sed -i '/AllowUsers/a AllowUsers something7' /etc/ssh/sshd_config
++ awk -F: '$3 == 1000 { print $1 }' /etc/passwd
+ USERNAME=something78
+ grep 'AllowUsers something78' /etc/ssh/sshd_config
+ sed -i '/AllowUsers/a AllowUsers something78' /etc/ssh/sshd_config
+ echo 'chmod 644 /etc/ssh/sshd_config'
chmod 644 /etc/ssh/sshd_config
+ echo '/etc/init.d/ssh restart'
/etc/init.d/ssh restart

问题:

如何AllowedUsers在sshd_config没有重复项的情况下添加用户?你也知道我的代码中发生了什么吗?

sshd sed
  • 2 个回答
  • 660 Views
Martin Hope
somethingSomething
Asked: 2018-09-07 10:19:46 +0800 CST

sed 有多个命令,我可以使用 w(写)标志吗?

  • 0

我在这里学习sed,这里有多个命令:

(user@host)-(18:27:39)-(~/Bash_Programming)
$sed '4 { s/fox/elephant/; s/dog/cat/ }' catAndDog.txt 
The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog
The quick brown elephant jumps over the lazy cat
The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog

但是,如果我使用多个命令并希望将结果写入文件,我应该将 w 替换标志放在哪里?

w file = write the result of the substitution to a file

编辑:

我想将整个输出写入文件,即原始文件的副本以及所做的更改。

text-processing sed
  • 3 个回答
  • 1107 Views
Martin Hope
somethingSomething
Asked: 2018-09-05 11:47:35 +0800 CST

“who -a”的输出是否正常?

  • 2

这对我来说看起来不正常:

who -a
           system boot  2018-09-04 11:59
LOGIN      tty1         2018-09-04 11:59               685 id=tty1
           run-level 5  2018-09-04 11:59
user + pts/0        2018-09-04 20:39   .         19612 (192.168.1.173)
user + pts/1        2018-09-04 12:15 08:27        9252 (:0)
           pts/2        2018-09-04 13:02             12256 id=ts/2  term=0 exit=0
           pts/3        2018-09-04 13:02             12265 id=ts/3  term=0 exit=0
           pts/4        2018-09-04 13:02             12274 id=ts/4  term=0 exit=0
           pts/5        2018-09-04 13:02             12283 id=ts/5  term=0 exit=0
           pts/6        2018-09-04 13:02             12293 id=ts/6  term=0 exit=0
           pts/7        2018-09-04 13:02             12302 id=ts/7  term=0 exit=0
           pts/8        2018-09-04 13:02             12311 id=ts/8  term=0 exit=0
           pts/9        2018-09-04 13:02             12320 id=ts/9  term=0 exit=0
           pts/10       2018-09-04 13:02             12329 id=s/10  term=0 exit=0
           pts/11       2018-09-04 13:02             12338 id=s/11  term=0 exit=0
           pts/12       2018-09-04 13:02             12347 id=s/12  term=0 exit=0
           pts/14       2018-09-04 12:39             11677 id=s/14  term=0 exit=0
           pts/15       2018-09-04 12:39             11687 id=s/15  term=0 exit=0
           pts/18       2018-09-04 12:18             10435 id=s/18  term=0 exit=0
           pts/22       2018-09-04 12:03              5066 id=s/22  term=0 exit=0
           pts/23       2018-09-04 12:03              5075 id=s/23  term=0 exit=0
           pts/24       2018-09-04 12:03              5084 id=s/24  term=0 exit=0
           pts/25       2018-09-04 12:03              5093 id=s/25  term=0 exit=0
           pts/26       2018-09-04 12:03              5102 id=s/26  term=0 exit=0
           pts/27       2018-09-04 12:03              5112 id=s/27  term=0 exit=0
           pts/28       2018-09-04 12:03              5121 id=s/28  term=0 exit=0
           pts/29       2018-09-04 12:03              5130 id=s/29  term=0 exit=0
           pts/30       2018-09-04 12:03              5139 id=s/30  term=0 exit=0
           pts/31       2018-09-04 12:03              5148 id=s/31  term=0 exit=0
           pts/32       2018-09-04 12:03              5157 id=s/32  term=0 exit=0
           pts/33       2018-09-04 12:03              5166 id=s/33  term=0 exit=0
           pts/34       2018-09-04 12:03              5175 id=s/34  term=0 exit=0
           pts/35       2018-09-04 12:03              5184 id=s/35  term=0 exit=0
           pts/36       2018-09-04 12:03              5193 id=s/36  term=0 exit=0
           pts/46       2018-09-04 12:00              2093 id=s/46  term=0 exit=0
           pts/47       2018-09-04 12:00              2102 id=s/47  term=0 exit=0
           pts/48       2018-09-04 12:00              2111 id=s/48  term=0 exit=0
           pts/49       2018-09-04 12:00              2120 id=s/49  term=0 exit=0
           pts/50       2018-09-04 12:00              2129 id=s/50  term=0 exit=0
           pts/51       2018-09-04 12:00              2138 id=s/51  term=0 exit=0
           pts/52       2018-09-04 12:00              2147 id=s/52  term=0 exit=0
           pts/53       2018-09-04 12:00              2156 id=s/53  term=0 exit=0
           pts/54       2018-09-04 12:00              2165 id=s/54  term=0 exit=0
           pts/55       2018-09-04 12:00              2174 id=s/55  term=0 exit=0
           pts/56       2018-09-04 12:00              2183 id=s/56  term=0 exit=0
           pts/57       2018-09-04 12:00              2192 id=s/57  term=0 exit=0
           pts/58       2018-09-04 12:00              2201 id=s/58  term=0 exit=0
           pts/59       2018-09-04 12:00              2210 id=s/59  term=0 exit=0
           pts/60       2018-09-04 12:00              2219 id=s/60  term=0 exit=0
           pts/61       2018-09-04 12:00              2228 id=s/61  term=0 exit=0
           pts/62       2018-09-04 12:00              2238 id=s/62  term=0 exit=0
           pts/63       2018-09-04 12:00              2247 id=s/63  term=0 exit=0
           pts/64       2018-09-04 12:00              2256 id=s/64  term=0 exit=0
           pts/65       2018-09-04 12:00              2265 id=s/65  term=0 exit=0
           pts/66       2018-09-04 12:00              2274 id=s/66  term=0 exit=0
           pts/67       2018-09-04 12:00              2283 id=s/67  term=0 exit=0
           pts/68       2018-09-04 12:00              2292 id=s/68  term=0 exit=0
           pts/69       2018-09-04 12:00              2301 id=s/69  term=0 exit=0
           pts/70       2018-09-04 12:00              2310 id=s/70  term=0 exit=0
           pts/71       2018-09-04 12:00              2319 id=s/71  term=0 exit=0
           pts/72       2018-09-04 12:00              2328 id=s/72  term=0 exit=0
           pts/73       2018-09-04 12:00              2337 id=s/73  term=0 exit=0
           pts/74       2018-09-04 12:00              2346 id=s/74  term=0 exit=0
           pts/75       2018-09-04 12:00              2355 id=s/75  term=0 exit=0
           pts/76       2018-09-04 12:00              2364 id=s/76  term=0 exit=0
           pts/77       2018-09-04 12:00              2373 id=s/77  term=0 exit=0
           pts/78       2018-09-04 12:00              2403 id=s/78  term=0 exit=0
           pts/79       2018-09-04 12:00              2412 id=s/79  term=0 exit=0
           pts/80       2018-09-04 12:00              2421 id=s/80  term=0 exit=0
           pts/81       2018-09-04 12:00              2431 id=s/81  term=0 exit=0
           pts/82       2018-09-04 12:00              2440 id=s/82  term=0 exit=0
           pts/83       2018-09-04 12:00              2449 id=s/83  term=0 exit=0
           pts/84       2018-09-04 12:00              2458 id=s/84  term=0 exit=0
           pts/85       2018-09-04 12:00              2467 id=s/85  term=0 exit=0
           pts/86       2018-09-04 12:00              2476 id=s/86  term=0 exit=0
           pts/87       2018-09-04 12:00              2485 id=s/87  term=0 exit=0
           pts/88       2018-09-04 12:00              2494 id=s/88  term=0 exit=0
           pts/89       2018-09-04 12:00              2503 id=s/89  term=0 exit=0
           pts/90       2018-09-04 12:00              2512 id=s/90  term=0 exit=0
           pts/91       2018-09-04 12:00              2521 id=s/91  term=0 exit=0
           pts/92       2018-09-04 12:00              2530 id=s/92  term=0 exit=0
           pts/93       2018-09-04 12:00              2539 id=s/93  term=0 exit=0
           pts/94       2018-09-04 12:00              2548 id=s/94  term=0 exit=0
           pts/95       2018-09-04 12:00              2599 id=s/95  term=0 exit=0
           pts/96       2018-09-04 12:00              2657 id=s/96  term=0 exit=0
           pts/97       2018-09-04 12:00              2710 id=s/97  term=0 exit=0
           pts/98       2018-09-04 12:00              2755 id=s/98  term=0 exit=0
           pts/99       2018-09-04 12:00              2784 id=s/99  term=0 exit=0
           pts/100      2018-09-04 12:00              2809 id=/100  term=0 exit=0
           pts/101      2018-09-04 12:00              2818 id=/101  term=0 exit=0
           pts/102      2018-09-04 12:00              2827 id=/102  term=0 exit=0
           pts/103      2018-09-04 12:00              2836 id=/103  term=0 exit=0
           pts/104      2018-09-04 12:00              2845 id=/104  term=0 exit=0
           pts/105      2018-09-04 12:00              2854 id=/105  term=0 exit=0
           pts/106      2018-09-04 12:00              2863 id=/106  term=0 exit=0
           pts/107      2018-09-04 12:00              2872 id=/107  term=0 exit=0
           pts/108      2018-09-04 12:00              2881 id=/108  term=0 exit=0
           pts/109      2018-09-04 12:00              2890 id=/109  term=0 exit=0
           pts/110      2018-09-04 12:00              2899 id=/110  term=0 exit=0
           pts/111      2018-09-04 12:00              2908 id=/111  term=0 exit=0
           pts/112      2018-09-04 12:00              2917 id=/112  term=0 exit=0
           pts/113      2018-09-04 12:00              2926 id=/113  term=0 exit=0
           pts/114      2018-09-04 12:00              2935 id=/114  term=0 exit=0
           pts/115      2018-09-04 12:00              2944 id=/115  term=0 exit=0
           pts/116      2018-09-04 12:00              2953 id=/116  term=0 exit=0
           pts/117      2018-09-04 12:00              2962 id=/117  term=0 exit=0
           pts/118      2018-09-04 12:00              2971 id=/118  term=0 exit=0
           pts/119      2018-09-04 12:00              2981 id=/119  term=0 exit=0
           pts/120      2018-09-04 12:00              2990 id=/120  term=0 exit=0
           pts/121      2018-09-04 12:00              2999 id=/121  term=0 exit=0
           pts/122      2018-09-04 12:00              3008 id=/122  term=0 exit=0
           pts/123      2018-09-04 12:00              3017 id=/123  term=0 exit=0
           pts/124      2018-09-04 12:00              3026 id=/124  term=0 exit=0
           pts/125      2018-09-04 12:00              3035 id=/125  term=0 exit=0
           pts/126      2018-09-04 12:00              3044 id=/126  term=0 exit=0
           pts/127      2018-09-04 12:00              3053 id=/127  term=0 exit=0
           pts/128      2018-09-04 12:00              3062 id=/128  term=0 exit=0
           pts/129      2018-09-04 12:00              3071 id=/129  term=0 exit=0
           pts/130      2018-09-04 12:00              3080 id=/130  term=0 exit=0
           pts/131      2018-09-04 12:00              3089 id=/131  term=0 exit=0
           pts/132      2018-09-04 12:00              3098 id=/132  term=0 exit=0
           pts/133      2018-09-04 12:00              3107 id=/133  term=0 exit=0
           pts/134      2018-09-04 12:00              3116 id=/134  term=0 exit=0
           pts/135      2018-09-04 12:00              3125 id=/135  term=0 exit=0
           pts/136      2018-09-04 12:00              3134 id=/136  term=0 exit=0
           pts/137      2018-09-04 12:00              3145 id=/137  term=0 exit=0
           pts/138      2018-09-04 12:00              3154 id=/138  term=0 exit=0
           pts/139      2018-09-04 12:00              3163 id=/139  term=0 exit=0
           pts/140      2018-09-04 12:00              3172 id=/140  term=0 exit=0
           pts/141      2018-09-04 12:00              3181 id=/141  term=0 exit=0
           pts/142      2018-09-04 12:00              3190 id=/142  term=0 exit=0
           pts/143      2018-09-04 12:00              3199 id=/143  term=0 exit=0
           pts/144      2018-09-04 12:00              3208 id=/144  term=0 exit=0
           pts/145      2018-09-04 12:00              3217 id=/145  term=0 exit=0
           pts/146      2018-09-04 12:00              3226 id=/146  term=0 exit=0
           pts/147      2018-09-04 12:00              3235 id=/147  term=0 exit=0
           pts/148      2018-09-04 12:00              3244 id=/148  term=0 exit=0
           pts/149      2018-09-04 12:00              3253 id=/149  term=0 exit=0
           pts/150      2018-09-04 12:00              3262 id=/150  term=0 exit=0
           pts/151      2018-09-04 12:00              3271 id=/151  term=0 exit=0
           pts/152      2018-09-04 12:00              3280 id=/152  term=0 exit=0
           pts/153      2018-09-04 12:00              3289 id=/153  term=0 exit=0
           pts/154      2018-09-04 12:00              3299 id=/154  term=0 exit=0
           pts/155      2018-09-04 12:00              3308 id=/155  term=0 exit=0
           pts/156      2018-09-04 12:00              3317 id=/156  term=0 exit=0

问题: 这是什么意思?

我在这个系统上还有另一个疯狂的问题。

debian login
  • 1 个回答
  • 163 Views
Martin Hope
somethingSomething
Asked: 2018-09-05 04:46:57 +0800 CST

awk 从 passwd 打印,但只有用户 ID > 1000

  • 0

好的,我已经完成了:

cat /etc/passwd | awk -F: '{ print $1 }'
  • -F ==> 指定一个文件分隔符来描述一行中的数据字段
  • $1 ==> 表示输入中的第一个字段

但是如何只打印带有idover 的用户1000?

awk scripting
  • 1 个回答
  • 1089 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve