我刚刚使用 VMware?12 将 Mint 18 安装为虚拟机。我遇到了无法安装 vmware-tools 的问题。一开始我尝试按照Mint的推荐安装open-vm-tools,但是没有用,所以我卸载了它,然后尝试安装默认的vmware-tools,但无法安装。
我正在尝试构建一个 awk 语句来读取此文件:
A 1,2,3 *
A 4,5,6 **
B 1
B 4,5 *
Run Code Online (Sandbox Code Playgroud)
并构建一个这样的文件:
A 1,2,3 * 3 1 0.333
A 4,5,6 ** 3 2 0.666
B 1 1 0 0
B 4,5 * 2 1 0.5
Run Code Online (Sandbox Code Playgroud)
在这个新文件中,前三列与原始文件中的相同。第四列必须包含第 2 列中逗号分隔的元素数。第五列必须包含第 3 列中的字符数。最后一列包含第 5 列在第 4 列中的比例(即第 5 列除以第 4 列)。
我正在尝试以下代码:
awk '{print $1"\t"$2"\t"$3"\t"(NF","$2 -1)"\t"length($3)"\t"(length($3)/(NF","$2-1))}' file1 > file2
Run Code Online (Sandbox Code Playgroud)
但我得到了以下输出:
A 1,2,3 * 3,0 1 0.333333
A 4,5,6 ** 3,3 2 0.666667
B 1 2,0 0 0
B 4,5 * …Run Code Online (Sandbox Code Playgroud) 如果我输入
cat > file.txt 2>&1
Run Code Online (Sandbox Code Playgroud)
然后file.txt使用cat的标准输入的内容创建。但如果我这样做
cat > file.txt 1>&2
Run Code Online (Sandbox Code Playgroud)
然后file.txt创建,但文件是空的。
以上两个命令之间有什么问题?
我在客户端进程和服务器进程之间有一个套接字连接,它们都在我的机器上运行。有两个条目显示为连接,
sudo netstat -ntp | grep 56442
tcp 1 0 127.0.0.1:56442 127.0.0.1:8002 CLOSE_WAIT 8276/python
tcp 0 0 127.0.0.1:8002 127.0.0.1:56442 FIN_WAIT2 -
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我如何确定哪个是服务器?
我知道 TCP 服务器正在端口上运行8002,并且客户端从端口连接到侦听服务器56442。
我试图通过查看netstat输出条目找出一种区分服务器和客户端的方法。
为什么当套接字处于FIN_WAIT2状态时进程 ID/描述不出现?
使用 gdb 附加到进程时。表明
无法附加到进程。如果您的 uid 与目标进程的 uid 匹配,请检查 /proc/sys/kernel/yama/ptrace_scope 的设置,或以 root 用户身份重试。有关更多详细信息,请参阅 /etc/sysctl.d/10-ptrace.conf
ptrace:不允许操作。
作为 root 我使用echo 0 >/proc/sys/kernel/yama/ptrace_scope; 然后它显示:
bash: /proc/sys/kernel/yama/ptrace_scope: 只读文件系统
我该如何解决这个问题?的内容/etc/sysctl.d/10-ptrace.conf是kernel.yama.ptrace_scope = 0
我在文件中有这样的路径名列表:
/path/to/directory/one.txt
/longer/path/to/some/directory/two.py
/path/with spaces/in/it/three.sh
Run Code Online (Sandbox Code Playgroud)
我想删除最后一次出现“/”后的所有字符,因此上述所需的输出是:
/path/to/directory/
/longer/path/to/some/directory/
/path/with spaces/in/it/
Run Code Online (Sandbox Code Playgroud) linux command-line ubuntu text-processing regular-expression
我需要在本HEAD节结束之前将一些文本插入到 HTML 文件中。
我想:
sed -i "s#</head>#<style> @page { prince-shrink-to-fit: auto }
.repository-with-sidebar.with-full-navigation .repository-content
{width: 950px ! important;} </style>\n</head>#" ${1}"/"${2}"/"${i}.html
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
sed: 1: command a expects \ followed by text
Run Code Online (Sandbox Code Playgroud)
我只是没有看到我的错误。我什至尝试在样式周围使用单引号。
我想在本HEAD节末尾插入的确切文本是:
<style>
@page { prince-shrink-to-fit: auto }
.repository-with-sidebar.with-full-navigation .repository-content
{width: 950px ! important;}
</style>
Run Code Online (Sandbox Code Playgroud)
编辑:这是确切的命令:
sed -i "s#</head>#<style> @page { prince-shrink-to-fit: auto } .repository-with-sidebar.with-full-navigation .repository-content {width: 950px ! important;} </style>\n</head>#" ${1}"/"${2}"/"${i}.html
Run Code Online (Sandbox Code Playgroud)
编辑 2:为了尝试确保我正确格式化命令,我也在尝试这个:
strToInsert='<style> @page { prince-shrink-to-fit: auto } .repository-with-sidebar.with-full-navigation .repository-content {width: 950px ! important;} …Run Code Online (Sandbox Code Playgroud) 我想要给定日期之后下一个星期六的日期。例如,对于$date1="30-AUG-2015",我想要结果 05-SEP-2015。
我已经尝试了以下所有命令但没有成功:
samba@samba:~$ date1="30-AUG-2015"
samba@samba:~$ date2=$(date --date='"$date1" +next Saturday')
date: invalid date ‘"$date1" +next Saturday’
samba@samba:~$ date1="30-AUG-2015"
samba@samba:~$ date2=$(date --date1='next Saturday')
date: unrecognized option '--date1=next Saturday'
Try 'date --help' for more information.
samba@samba:~$ date1="30-AUG-2015"
samba@samba:~$ date -d "$date1 next saturday"
Sun Aug 30 00:00:00 IST 2015
samba@samba:~$ $date1 -d "next saturday"
30-AUG-2015: command not found
Run Code Online (Sandbox Code Playgroud) 我的Wi-Fi将不会在下班后暂停,但WILL下班后冬眠。 我已经尝试了几件事并且有一些运气,所以我会发布我所做的事情以及我所看到的效果。
$ sudo lshw
description: Notebook
product: HP ENVY 14 Notebook PC (J9L59UA#ABA)
vendor: Hewlett-Packard
version: 096C120014405F10000620182
serial: 5CD5143D9B
width: 64 bits
capabilities: smbios-2.7 dmi-2.7 vsyscall32
configuration: administrator_password=disabled boot=normal chassis=notebook family=103C_5335KV G=N L=CON B=HP S=ENV X=Null sku=J9L59UA#ABA uuid=35434435-3134-3344-3942-D0BF9C9A90FA
*-core
description: Motherboard
product: 2298
vendor: Hewlett-Packard
physical id: 0
version: 78.21
serial: PEWNT018J8I1ER
slot: Type2 - Board Chassis Location
*-firmware
description: BIOS
vendor: Insyde
physical id: 0
version: F.36
date: 02/02/2015
size: 128KiB
capacity: 6080KiB …Run Code Online (Sandbox Code Playgroud) 是否可以使用管道命令作为 find-exec选项的参数?这意味着,我想做这样的事情:
find . -name CMakeLists* -exec cat '{}' | grep lib \;
Run Code Online (Sandbox Code Playgroud)
我试图cat '{}' | grep lib为每个文件执行的地方,但这不起作用。引用也不起作用。有人有建议吗?
更新:
特定的问题得到了回答。现在,有没有办法让通用find <path> -type f -name <name> -exec <pipeline-command>模式起作用?