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

Rick T's questions

Martin Hope
Rick T
Asked: 2019-12-12 10:22:09 +0800 CST

使用存储在变量中的文件名的头部的语法[重复]

  • 0
这个问题在这里已经有了答案:
如何将命令的输出分配给 shell 变量? (3 个回答)
2年前关闭。

我正在尝试将文件中的前 5 行存储在变量中url。但我得到一个错误

-n5: command not found

fn_all_urls存储文件的路径/home/urls.txt

我的线路是:

url=head -n5 ${fn_all_urls} #get first 5 lines in file
echo "$url"

我在 Ubuntu 18.04 64 位上使用 bash

bash head
  • 1 个回答
  • 1926 Views
Martin Hope
Rick T
Asked: 2019-12-10 12:17:50 +0800 CST

无头铬浏览器命令语法问题

  • 0

我遇到了一些关于无头铬浏览器没有正确创建 html 文件的问题。唯一创建的东西/文件是单个{}.html文件

我的 domain.txt 包含:

https://ibm.com/ 
https://www.linux.org/whats-new/

PS:我使用的是 Ubuntu 18.04 64bit linux

我使用的命令如下:

cat domains.txt | xargs -I {} -P 4 sh -c timeout 25s chromium-browser --headless --no-sandbox --user-agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537. 36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36' --dump-dom https://{} 2> /dev/null > {}.html

这是取自此链接

linux shell-script
  • 1 个回答
  • 170 Views
Martin Hope
Rick T
Asked: 2019-12-05 14:14:07 +0800 CST

解析 sed 问题

  • 0

我有一个文本文件0test.txt,其中包含以下代码片段。 (它有几个 http 和 https url 链接,但这些行将其单独列出)

player.setup({
  file: 'http://website.com/site/myStream/playlist.m3u8?wmsAuthSign=c2VydmVyXs',
  width: "100%",
  aspectratio: "16:9",

});

我可以运行一个sed命令:

cat /tmp/0test.txt | sed -n -e "/^ *file: */ { s/^ *file: *'//; s/', *$//p}"

并取回正确的 URL 链接:

http://website.com/site/myStream/playlist.m3u8?wmsAuthSign=c2VydmVyXs

但是当文件0test.txt看起来像这样时:

player.setup({
          file: 
'http://website.com/site/myStream/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9MTIvNC8yMDE5IDk6MTY6NTggUE0maGFzaF92YWx1ZT16RXpiUWowQ0V4TDJER3ExQnFZTEd3PT0mdmFsaWRtaW51dGVzPTM2MCZzdHJtX2xlbj0w',
          width: "100%",
          aspectratio: "16:9",
            aspectratio: "16:9"

    });

我没有得到任何回报。我怎样才能解决这个问题?

sed
  • 3 个回答
  • 110 Views
Martin Hope
Rick T
Asked: 2019-11-10 18:28:37 +0800 CST

使用 bash 附加多个文件并使用 SWAKS 或其他程序通过电子邮件发送

  • 0

我试着:

  1. 将多个文件附加到一封电子邮件中。
  2. 使用 Gmail 帐户发送电子邮件,并在主题标头中包含当前日期和时间。

我在使用 for 循环时遇到了问题,因为我不想创建多封电子邮件,我只想创建一封包含所有附件的电子邮件,并在主题行中使用当前日期和时间。

#!/bin/bash
# to run type "bash email_live_listing.sh"

dt_now_start=`date +"%Y-%m-%d %T"`
fn_dt_now_start=`date '+%Y_%m_%d__%H_%M_%S'`; #use to generate file name with date
currentdir="$(pwd)" #get current directory


ls $currentdir/us*.pdf -tp | grep -v '/$fn_pdf' #place files into variable

echo "$fn_pdf"

ITER=0
for t in ${fn_pdf[@]}; do
swaks --to to@gmail.com -s smtp.gmail.com:587 -tls -au from@gmail.com -ap password --header "Subject: Updated file ${fn_dt_now_start}" --body "Email Text" --attach-type ./${fn_pdf} -S 2
let ITER+=1 #increment number
done

Ps:我正在使用 Ubuntu 和Swaks,因为它小巧轻便,并且可以从 raspberry pi 运行,但我愿意尝试其他选项。

email
  • 1 个回答
  • 1256 Views
Martin Hope
Rick T
Asked: 2019-10-31 18:15:57 +0800 CST

用空格递归替换目录和子目录名称中的所有点

  • 0

使用 bash 我试图用空格替换目录名称中的所有点及其子目录。

示例:目录dir.1.3 将变为dir 1 3

我到目前为止的脚本:

#!/bin/bash    
for dir in *\ -\ *; do

      [[ -d "$dir" ]] || continue   # skip if not a directory
      sub="${dir#* - }"
      if [[ ! -e "$sub" ]]; then
        mv "$dir" "$sub"
        mv echo "$(echo "Result: ${dir%.*}" | sed 's/\./ /g').${dir##*.}"

      fi
done
bash
  • 1 个回答
  • 300 Views
Martin Hope
Rick T
Asked: 2019-08-25 23:03:05 +0800 CST

使用 bash 解析 wget 和 grep 的输出

  • 2

我可以获得一个 url 链接并搜索以file:开头的文本, 但我在从那里解析它时遇到了问题。

例子:

wget -qO- http://website.com/site/ | tr \" \\n | grep -w file:\* > output.txt

wget 命令给了我输出:

file: 'http://website.com/site/myStream/playlist.m3u8?wmsAuthSign=c2VydmVyXs',

我试图让输出看起来像。

http://website.com/site/myStream/playlist.m3u8?wmsAuthSign=c2VydmVyXs

我的目标是拥有一个 bash 脚本,其中包含将循环通过的多个源/url 列表,并且每个已处理/grep 的输出 url 将位于其自己的单独行上。

http://website.com/site/myStream/playlist.m3u8?wmsAuthSign=c2VydmVyXs

按照要求:

wget -qO- http://website.com/site/ 这是发回内容的输出示例 。

player.setup({
  file: 'http://website.com/site/myStream/playlist.m3u8?wmsAuthSign=c2VydmVyXs',
  width: "100%",
  aspectratio: "16:9",

});
bash grep
  • 1 个回答
  • 3928 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