序列{1,2,3}和之间有区别{1..3}吗?
例如,如果我有一些文件
file.1
file.2
file.3
Run Code Online (Sandbox Code Playgroud)
我想把cat它们放在一起使用安全cat file.{1..3} > file吗?
我知道这cat file.*>file可能会导致问题,因为外壳有时会以随机方式扩展文件(我认为这取决于 inode,是吗?)
为什么这是有效的:
mkdir /dir/test{1,2,3}
Run Code Online (Sandbox Code Playgroud)
这不是吗?
{chown httpd,chmod 700} /dir/test1
-bash: {chown: command not found
Run Code Online (Sandbox Code Playgroud)
我的 Bash 版本是:GNU bash,版本 4.2.46(2)-release
这是一个理论问题。
为什么我只能有 29 个交换文件/分区?
如果我想生成 10k 1MB 交换文件并交换它们,则在 30 交换文件处失败,并显示 swapon: /tmp/swap29: swapon failed: 不允许操作
实现此目的的脚本
#!/bin/bash
i=0
SWAP=/tmp/swap
while [ "$i" -lt 10000 ];do
dd if=/dev/urandom of=$SWAP$i bs=1M count=1
mkswap "${SWAP}${i}"
swapon "${SWAP}${i}"
i=$((i+1))
done
Run Code Online (Sandbox Code Playgroud)
有人可以解释一下吗?
每天午夜后的几分钟,updatedb.findutils 运行以索引一些文件。这是一个程序,随 Ubuntu 一起提供。现在我想知道这个程序做了什么并找到了这个。
root 12500 12491 0 00:10 ? 00:00:00 /bin/sh /usr/bin/updatedb.findutils
root 12533 12500 0 00:10 ? 00:00:00 su nobody -s /bin/sh -c /usr/bin/find / -ignore_readdir_race \( -fstype NFS -o -fstype nfs -o -fstype nfs4 -o -fstype afs -o -fstype binfmt_misc -o -fstype proc -o -fstype smbfs -o -fstype autofs -o -fstype iso9660 -o -fstype ncpfs -o -fstype coda -o -fstype devpts -o -fstype ftpfs -o -fstype devfs -o -fstype mfs -o -fstype shfs -o -fstype sysfs -o …Run Code Online (Sandbox Code Playgroud) 我想知道更改到调用脚本的目录的安全或 Unix 兼容方式是什么。
这两种方法甚至可以在包含空格和特殊字符的目录中工作,而无需使用引号。但是在某些情况下这可能不起作用。或者有吗?
#!/bin/bash
cd $(dirname $0)
pwd
cd ${0%/*}
pwd
~/test 1"\ ü`\($$ ./cd.sh
/home/syss/test 1"\ ü`\($
/home/syss/test 1"\ ü`\($
Run Code Online (Sandbox Code Playgroud)