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-40484

Paulo Tomé's questions

Martin Hope
Paulo Tomé
Asked: 2020-02-11 04:53:00 +0800 CST

路径名中的文件名,不包括(未知)扩展名

  • 0

有了路径名,就可以提取它的filename,不包括它的先验已知扩展名,basename:

$ pathname="/home/paulo/paulo.pdf"
$ printf "%s\n" "$(basename $pathname .pdf)"
paulo

但是,如果不知道扩展名怎么办?

shell filenames
  • 3 个回答
  • 141 Views
Martin Hope
Paulo Tomé
Asked: 2020-01-27 15:28:05 +0800 CST

我计算机上的处理器、磁盘和内部总线的运行速度是否足以以每秒 10 Gb 的速度从磁盘文件发送数据?

  • -1

我想知道我计算机上的处理器、磁盘和内部总线是否运行得足够快,可以以每秒 10 Gb 的速度从磁盘文件发送数据?

% cat /proc/cpuinfo

processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 58
model name  : Intel(R) Core(TM) i7-3537U CPU @ 2.00GHz
stepping    : 9
microcode   : 0x21
cpu MHz     : 1286.233
cache size  : 4096 KB
physical id : 0
siblings    : 4
core id     : 0
cpu cores   : 2
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts md_clear flush_l1d
bugs        : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit
bogomips    : 4988.39
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual



% sudo smartctl -a /dev/sda         
smartctl 6.6 2017-11-05 r4594 [x86_64-linux-4.19.0-6-amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Toshiba 2.5" HDD MQ01ABD...
Device Model:     TOSHIBA MQ01ABD075
Serial Number:    33BWT0STT
LU WWN Device Id: 5 000039 4a1f83658
Firmware Version: AX0R2J
User Capacity:    750,156,374,016 bytes [750 GB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
Form Factor:      2.5 inches
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ATA8-ACS (minor revision not indicated)
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Sun Jan 26 23:16:14 2020 WET
SMART support is: Available - device has SMART capability.
SMART support is: Enabled



% lspci -tv
-[0000:00]-+-00.0  Intel Corporation 3rd Gen Core processor DRAM Controller
           +-01.0-[01]----00.0  NVIDIA Corporation GK107M [GeForce GT 740M]
           +-02.0  Intel Corporation 3rd Gen Core processor Graphics Controller
           +-04.0  Intel Corporation 3rd Gen Core Processor Thermal Subsystem
           +-14.0  Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller
           +-16.0  Intel Corporation 7 Series/C216 Chipset Family MEI Controller #1
           +-1a.0  Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #2
           +-1b.0  Intel Corporation 7 Series/C216 Chipset Family High Definition Audio Controller
           +-1c.0-[02]--
           +-1c.1-[03]----00.0  Qualcomm Atheros AR9485 Wireless Network Adapter
           +-1c.3-[04]--+-00.0  Realtek Semiconductor Co., Ltd. RTL8411 PCI Express Card Reader
           |            \-00.2  Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
           +-1d.0  Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #1
           +-1f.0  Intel Corporation HM76 Express Chipset LPC Controller
           +-1f.2  Intel Corporation 7 Series Chipset Family 4-port SATA Controller [IDE mode]
           +-1f.3  Intel Corporation 7 Series/C216 Chipset Family SMBus Controller
           \-1f.5  Intel Corporation 7 Series Chipset Family 2-port SATA Controller [IDE mode]

hard-disk performance
  • 1 个回答
  • 40 Views
Martin Hope
Paulo Tomé
Asked: 2020-01-18 10:00:29 +0800 CST

具有在文件最后一行添加尾随换行符的副作用的 Grep 命令

  • 1

我一直在研究如何从最后一行可能没有尾随换行符的文件中正确读取行。在Read a line-oriented file which may not end with a newline中找到了答案。

但是,我有第二个目标是排除行首的注释,并找到了grep实现目标的命令

$ grep -v '^ *#' file

但是我注意到这个命令有一个(对我来说出乎意料的)副作用:如果它不存在,它会在最后一行添加一个尾随换行符

$ cat file
# This is a commentary
aaaaaa
# This is another commentary
bbbbbb
cccccc

$ od -c file
0000000   #       T   h   i   s       i   s       a       c   o   m   m
0000020   e   n   t   a   r   y  \n   a   a   a   a   a   a  \n   #
0000040   T   h   i   s       i   s       a   n   o   t   h   e   r
0000060   c   o   m   m   e   n   t   a   r   y  \n   b   b   b   b   b
0000100   b  \n   c   c   c   c   c   c  \n
0000111

$ truncate -s -1 file

$ od -c file
0000000   #       T   h   i   s       i   s       a       c   o   m   m
0000020   e   n   t   a   r   y  \n   a   a   a   a   a   a  \n   #
0000040   T   h   i   s       i   s       a   n   o   t   h   e   r
0000060   c   o   m   m   e   n   t   a   r   y  \n   b   b   b   b   b
0000100   b  \n   c   c   c   c   c   c
0000110

$ od -c <(grep -v '^ *#' file)
0000000   a   a   a   a   a   a  \n   b   b   b   b   b   b  \n   c   c
0000020   c   c   c   c  \n
0000025

请注意,除了删除行开头的注释外,它还在最后一行添加了尾随换行符。

怎么可能?

grep regular-expression
  • 1 个回答
  • 268 Views
Martin Hope
Paulo Tomé
Asked: 2020-01-17 08:03:53 +0800 CST

在流中用 1 替换 0 和反之亦然的最快方法是什么?

  • 23

0给定一个由s 和s组成的字符串1,我的目标是将 0 替换为 1,反之亦然。例子:

输入

111111100000000000000

预期输出

000000011111111111111

我尝试了以下sed命令,但未成功

echo '111111100000000000000' | sed -e 's/0/1/g ; s/1/0/g'
000000000000000000000

我错过了什么?

text-processing sed
  • 5 个回答
  • 4522 Views
Martin Hope
Paulo Tomé
Asked: 2020-01-16 05:44:12 +0800 CST

行注释字符 '#' 和 shell 脚本中实际注释开始之间的空格

  • 2

存在其中注释在井号和实际注释之间有空格的 shell 脚本

# a comment at the beginning of a line
echo foo # a comment trailing after a command

和其他没有的

#another comment at the beginning of a line
echo bar #another comment trailing after a command

这个决定是否会对脚本的实际执行产生某种影响,还是(只是)一个编码风格问题?

shell-script shell
  • 2 个回答
  • 743 Views
Martin Hope
Paulo Tomé
Asked: 2019-12-20 06:54:44 +0800 CST

从字符位置获取行号

  • 0

在这个问题Get line number from character position我知道可以在文本文件中使用脚本从字符位置获取行号。

Emacs 具有M-x-goto-char将光标定位在字符位置的功能。

我的问题是:是否有任何 UNIX 实用程序可以以优雅的方式完成工作?

text-processing
  • 1 个回答
  • 876 Views
Martin Hope
Paulo Tomé
Asked: 2019-11-28 07:47:50 +0800 CST

从查找结果中排除隐藏目录中的文件,但不排除隐藏文件(在非隐藏目录下)

  • 1

给定以下目录结构:

$ tree --noreport dir

dir
├── fileA
├── .hiddenfileA
├── .hiddendirA
|   ├── .hiddenfileB
│   ├── fileC
│   └── fileD
└── dirA
    ├── .hiddenfileC
    ├── fileE
    └── fileF

要求是调用 find 以便从结果中排除来自隐藏目录但不是隐藏文件(在非隐藏目录下)的文件。

预期回报应该类似于:

./.hiddenfileA
./dirA/.hiddenfileC
./dirA/fileE
./dirA/fileF
./fileA

做了一些研究并在这里找到了导致我创建以下调用的信息find

$ find . -type f -not -path '*/\.*' -print

但是这个解决方案的缺点是跳过了隐藏的目录和文件。

find directory
  • 2 个回答
  • 126 Views
Martin Hope
Paulo Tomé
Asked: 2019-11-26 15:28:12 +0800 CST

linux内核Makefile名称=“人民阵线”

  • 0

有人知道linux内核源Makefile名称中字符串“人民阵线”的含义吗?

> uname -a

Linux debian 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u2 (2019-11-11) x86_64 GNU/Linux

刚刚从 debian 官方仓库安装了内核源

 > sudo apt-get install linux-source

参考线:

> cat /usr/src/linux-source-4.19/Makefile | grep "NAME"
NAME = "People's Front"
linux kernel
  • 1 个回答
  • 176 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