我正在使用以下内容来创建 tgz 文件:
tar zcf - /usr/folder | split -b 30720m - /usr/archive.tgz
Run Code Online (Sandbox Code Playgroud)
现在我得到三个文件:archive.tgzaa、archive.tgzab 和 archive.tgzac
所以我想再次将这三个档案组合成一个 tgz 文件......
cat archive.tgza* | (tar x)
tar: Archive is compressed. Use -z option
tar: Error is not recoverable: exiting now
Run Code Online (Sandbox Code Playgroud)
然后我做了:
cat archive.tgza* | (tar z)
tar: You must specify one of the `-Acdtrux' options
Try `tar --help' or `tar --usage' for more information.
Run Code Online (Sandbox Code Playgroud)
然后最后:
cat archive.tgza* | (tar xz)
Run Code Online (Sandbox Code Playgroud)
工作,但它开始解压缩档案......我怎样才能简单地将它重新加入一个档案?
谢谢 !
这是代码(bash脚本):
echo "Pass for router:"
read -s pass
/usr/bin/expect <<EOD
spawn ssh 192.168.10.1 -l root 'opkg list-installed' > list-installed.txt
#echo @pass
expect "*password:*"
send "$pass\r"
interact
EOD
Run Code Online (Sandbox Code Playgroud)
问题是它什么都不返回。它不会创建本地文件“list-installed.txt”
这可能有什么问题?
我有一个 Bash 脚本,具有所有要执行的权限,我将它附加到一个 cron 作业,这个脚本基本上只杀死并重新启动一个特定的进程,奇怪的行为是,如果我通过终端运行脚本一切正常正如预期的那样,它会取消进程并重新启动它,但是当触发 cron 作业时,它只会取消进程,仅此而已......知道为什么会发生这种行为吗?谢谢
在 bash 中,我可以使用 && 和/或 || 制作测试条件 而不是 if/elif/else 块。
适用时,我倾向于使用 && 和/或 || 而不是构建一个 if 块。一种构造相对于另一种构造是否有任何现实世界的优势?
考虑以下示例:
1)
[[ -f /shared_disk/backups/daily.tar.bz2 ]] && echo "the coast is clear" || echo "run the dump"
Run Code Online (Sandbox Code Playgroud)
2)
if [[ -f /shared_disk/backups/daily.tar.bz2 ]]; then
echo "the coast is clear"
else
echo "run the dump"
fi
Run Code Online (Sandbox Code Playgroud) 我想知道这个语句到底在做什么,尤其是那awk部分。
ps aux | grep 'sidekiq 5' | grep -v grep | awk '{ print $2; }' | xargs kill -${2:-'TERM'}
Run Code Online (Sandbox Code Playgroud)
我知道整个管道应该杀死sidekiq进程。
我正在尝试使用 bash 脚本在循环中执行以下操作
file_size = 0
temp_size = 1
output_file
while (file_size != temp_size)
temp_size = file_size
download file
append to output_file if possible
file_size = sizeof(output_file)
Run Code Online (Sandbox Code Playgroud)
谢谢!
我只想递归扫描Documents而不是离开那个“父”文件夹。我的脚本递归地扫描我的整个文件系统,我不确定这个脚本的哪个元素导致了这种情况的发生。这就是我所拥有的:
#/bin/sh
for f in $(find /home/rmintz/Documents/ -type f -name "*jpg")
do
echo $f
done
Run Code Online (Sandbox Code Playgroud)
我需要改变什么才能让这个 bash 脚本只扫描Documents文件夹而不扫描其他任何东西?
我给人的印象是,这是扫描我的整个文件系统,因为终端中的输出显示/home/rmintz/Documents.
一个例子是/usr/lib。