linux - 将 Perl 脚本转换为 Bash

标签 linux perl bash wget tar

我在下面有一个 Perl 脚本,我想将它转换为 Bash 脚本,但遗憾的是我在 Bash 中遇到了困难。谁能帮我这个。

#!/usr/bin/perl

use strict;
use warnings;


my $output = `df -h`;
my $bundle = "`awk -F \'=\' \'{print \$2}\' config.txt`";
my $bundlename = `echo $bundle | awk -F \'/\' \'{print \$11}\'`;
print $output;

system ("wget $bundle");
print "$bundlename\n";
tar();


sub tar {
    my $cd = system ("tar -xzvf $bundlename") ;
    system ("rm -vf $bundlename");
}

谁能把它转换成 Bash 脚本?

最佳答案

#!/bin/sh
bundle=$(awk '$0=$2' FS== config.txt)
bundlename=$(awk '$0=$11' FS=/ <<< "$bundle")
dh -h
wget $bundle
echo $bundlename
tar -xzvf $bundlename
rm -vf $bundlename

关于linux - 将 Perl 脚本转换为 Bash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23331943/

相关文章:

c - 是否有任何 TCP 设置影响 SIGPIPE?

c++ - 调试和发布库及其可执行程序

perl - Perl 的 CGI.pm 可以处理 Firefox 的 &lt;input type ="file",多个 =""> 表单域吗?

bash - 如何在 find 命令的 exec 参数中使用管道?

php - 如何粗略估计 LAMP 应用容量?

linux - 共享 Xauthority 文件

perl - 如何在 Perl 中将 float 转换为十六进制字符串?

Perl 服务器端跨域检测

linux - 优化大文件的 grep 操作

bash - 我如何知道在 bash 中使用 awk 首先出现了哪个定界符?