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

alhelal's questions

Martin Hope
alhelal
Asked: 2018-03-31 01:44:36 +0800 CST

如果 csv 的分隔符出现在值中,我该怎么办?

  • 0

假设,我的 csv 文件包含

"item_name","price","description"
mobile,500$,It has many features (e.g., camera, big display, etc)  

我想使用 mysql 命令将这个 csv 数据文件加载到 mysql 数据库中

load data local infile 'file.csv' into table table
 fields terminated by ','
 lines terminated by '\n'
 (column1, column2, column3,...)  

你也可以说通过"和使用enclosed by '"'mysql的选项来包围每个值。但是封闭每个值对我来说都是开销。

description如果有一种解决方案可以读取这种类型的 csv,其中一列包含"但不是全部,我只能附上值。

csv
  • 2 个回答
  • 50 Views
Martin Hope
alhelal
Asked: 2018-03-22 08:41:45 +0800 CST

如何在bash中创建一个在其他人之间插入新文件名的函数?

  • 0

假设,我有一个名为的目录Titlepage,其中有许多名为titlepage_1.pdf, titlepage_2.pdf...的文件titlepage_n.pdf以及它们的tex文件。我有一个 bash 函数可以更改两个文件名。(例如$alterpdf 2 3,此命令将文件名交换titlepage_2.pdf为titlepage_3.pdf. 并对相应的文件执行相同的tex操作。)

function swap(){ mv $1 $1._tmp && mv $2 $1 && mv $1._tmp $2; }
function alterpdf(){ swap titlepage_$1.pdf titlepage_$2.pdf; swap titlepage_$1.tex titlepage_$2.tex; }  

现在,我想要一个函数(例如, ),它可以在内部filepush new.pdf 2 3插入并带有名称。并且下一个文件的数量会增加。到到等等。 new.pdftitlepage_2.pdftitlepage_3.pdftitlepage_3.pdftitlepage_3.pdftitlepage_4.pdf titlepage_4.pdftitlepage_5.pdf

该目录中还有一个.tex用于所有 pdf 的文件。

编辑
我想实现以下 -

Titlepage$ ls
titlepage_1.tex titlepage_1.pdf titlepage_2.tex titlepage_2.pdf titlepage_3.tex titlepage_3.pdf
Titlepage$ vim new.tex
Titlepage$ pdflatex new.tex
Titlepage$ ls
new.pdf new.tex titlepage_1.tex titlepage_1.pdf titlepage_2.tex titlepage_2.pdf titlepage_3.tex 
titlepage_3.pdf
Titlepage$ push new.pdf 2 3
Titlepage$ ls
titlepage_1.tex titlepage_1.pdf titlepage_2.tex titlepage_2.pdf titlepage_3.tex titlepage_3.pdf titlepage_4.tex titlepage_4.pdf

编辑
建议的解决方案

$ls *.pdf|grep -Eo [0-9]+|sort -n  

这会产生文件的索引。从尾部递增每个索引开始,为每个文件添加 1,直到插入点(的第二个参数push)。然后将目标文件(new.pdf)重命名为titlepage_3rd_argement_of_push.pdf

bash rename
  • 2 个回答
  • 85 Views
Martin Hope
alhelal
Asked: 2018-03-19 02:08:43 +0800 CST

如何从bash中的另一个用户定义函数调用用户定义函数?

  • -2

我想做这个 -

function swap(){ mv $1 $1._tmp && mv $2 $1 && mv $1._tmp $2; }
function alterpdf(){ swap(titlepage_$1.tex titlepage_$2.tex); swap(titlepage_$1.pdf,titlepage_$2.pdf); pdflatex allTitle    page.tex; }  

我的swap功能运行良好。现在,我想在swap函数内部使用alterpdf函数。但是,这会产生错误——

在此处输入图像描述

bash-functions
  • 1 个回答
  • 203 Views
Martin Hope
alhelal
Asked: 2018-03-16 17:51:44 +0800 CST

如何从许多pdf中制作一个pdf,其中它们的文件名也显示在一个pdf中?

  • 0

我有一个名为Titlepage文件(最少 10 个 pdf)所在的目录titlepage_1.pdf,titlepage_2.pdf... titlepage_3.pdf每个都是一页pdf。

该目录也托管在 Github 中,以便人们可以轻松下载标题页。Github 目录也包含相应的 LaTeX 文件。

我想使用这些制作一个组合的 pdf,其中每页包含 4 个 pdf。并且每个扉页也有自己的原名。这样任何人都可以通过比较一个pdf中的所有内容来选择pdf,然后下载他需要的扉页。

[我想它可以使用pdfuite. 如果无法使用,则仅与] pdfunite结合使用LaTeX

在此处输入图像描述

或者

在此处输入图像描述

编辑

在此处输入图像描述

pdf
  • 2 个回答
  • 101 Views
Martin Hope
alhelal
Asked: 2018-03-12 20:34:50 +0800 CST

如何搜索存储在变量中的文本?

  • 1
#!/bin/bash
num=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings | grep -oE '[0-9]+'|sort -rn|head -n 1)
key=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings)
newnum=$(grep -oE '[0-9]+' $key |sort -rn|head -n 1)
echo $newnum

grep采用$keyas 文件名,但我希望它搜索存储在变量中的文本$text。

bash text-processing
  • 1 个回答
  • 255 Views
Martin Hope
alhelal
Asked: 2018-02-21 20:03:09 +0800 CST

有没有办法在不打开文件的情况下复制剪贴板中的文件内容?[复制]

  • 2
这个问题在这里已经有了答案:
将文件的内容复制到剪贴板而不显示其内容 4 个答案
4年前关闭。

我总是使用 vim 作为我的文本编辑器。但是,当我想将完整文件的内容复制到剪贴板中以粘贴另一个位置时,我在 gedit 中打开文件,然后CtrlA按CtrlC。

在文本编辑器中打开文件并按CtrlA然后CtrlC对我来说是开销。因为我必须在文本编辑器中打开文件,虽然我不编辑文件。

因此,如果有任何命令可以将文件内容复制到剪贴板中,那就更好了。
例如
clip file.txt

在 vim 中也有可能通过映射CtrlA到某个命令或clip复制命令来获得此功能。但是,我不知道如何使用命令在 vim 中复制整个文件。

注意我的 vim 不支持+clipboard.

vim clipboard
  • 2 个回答
  • 14131 Views
Martin Hope
alhelal
Asked: 2018-01-07 17:42:37 +0800 CST

如何在 sed 中打印内联更改?

  • -1

我跑

sed -i -e 'expression1' -e 'expression2' -e 'expression3'...'expression1000' file

如何查看sed执行时所做的更改?

sed
  • 1 个回答
  • 761 Views
Martin Hope
alhelal
Asked: 2018-01-03 17:20:17 +0800 CST

是否可以在 CLI 中的文件开头添加一些文本而不创建新文件?

  • 1

我有两个文件;file1包含 -

hello world
hello bangladesh  

并file2包含 -

 Dhaka in Bangladesh
 Dhaka is capital of Bangladesh  

我想更新file2为 -

hello world
hello bangladesh 
Dhaka in Bangladesh
Dhaka is capital of Bangladesh

这是由 -

cat file1 file2 >> file3
mv file3 file2  

但是,我不想创建一个新文件。我想使用sed它可能是可能的。

text-processing sed
  • 4 个回答
  • 104 Views
Martin Hope
alhelal
Asked: 2018-01-01 18:38:03 +0800 CST

如何在包含前一行模式的文件中添加一个额外的行,该行也有一个模式?

  • 1

我有一个文件 -

something
\title{\hypertarget{A64L}{A64L(3)}}
something
\title{\hypertarget{MALLOC}{MALLOC(3)}}
something
\title{\hypertarget{STRCMP}{STRCMP(3)}}  

in 中的单词{}可以是任何东西,但 consecutive 中的单词相同{}。
我想得到

something
\title{\hypertarget{A64L}{A64L(3)}}
\addcontentsline{A64L}
something
\title{\hypertarget{MALLOC}{MALLOC(3)}}
\addcontentsline{MALLOC}
something
\title{\hypertarget{STRCMP}{STRCMP(3)}}
\addcontentsline{STRCMP}  

我尝试跟随,但失败了。

sed -e /\\\\title\{\\\\hypertarget\{.*\}\{.*\(3\)\}\}/a\\\\\\addcontentsline\{\&\} filename

这是https://tex.stackexchange.com/questions/408244/how-to-make-toc-without-having-any-section-parts-name的扩展

shell-script awk
  • 2 个回答
  • 45 Views
Martin Hope
alhelal
Asked: 2017-12-29 16:59:10 +0800 CST

用遵循模式的不同新字符串替换不同的字符串

  • 2

我有

\title{A64L(3)}
somethings
\textbf{a64l}()
\title{MALLOC(3)}
somethings
\textbf{malloc}()  

我想

\title{\hypertarget{a64l}{A64L(3)}}
somethings
\textbf{\hyperlink{a64l}{a64l}}()
\title{\hypertarget{malloc}{MALLOC(3)}}
somethings
\textbf{\hyperlink{malloc}{malloc}}()  

或者

\title{\hypertarget{a64l}{A64L}(3)}
somethings
\textbf{\hyperlink{a64l}{a64l}}()
\title{\hypertarget{malloc}{MALLOC}(3)}
somethings
\textbf{\hyperlink{malloc}{malloc}}()

这些是示例文件。可以有任何东西来代替A64Land MALLOC,但遵循模式(例如\title{new_word})。

我必须这样做才能获得描述的功能https://tex.stackexchange.com/questions/407884/how-to-make-a-title-as-link-target
我更喜欢vim, sed, awk.

您的答案也应该适用于以下 -

\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[utf8]{inputenc}
\else % if luatex or xelatex
  \ifxetex
    \usepackage{mathspec}
    \usepackage{xltxtra,xunicode}
  \else
    \usepackage{fontspec}
  \fi
  \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
  \newcommand{\euro}{€}
\fi
% use microtype if available
\IfFileExists{microtype.sty}{\usepackage{microtype}}{}
\usepackage{longtable,booktabs}
\ifxetex
  \usepackage[setpagesize=false, % page size defined by xetex
              unicode=false, % unicode breaks when used with xetex
              xetex]{hyperref}
\else
  \usepackage[unicode=true]{hyperref}
\fi
\hypersetup{breaklinks=true,
            bookmarks=true,
            pdfauthor={},
            pdftitle={A64L(3)},
            colorlinks=true,
            citecolor=blue,
            urlcolor=blue,
            linkcolor=magenta,
            pdfborder={0 0 0}}
\urlstyle{same}  % don't use monospace font for urls
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\setcounter{secnumdepth}{0}
\usepackage{pagecolor}

% Set background colour (of the page)
\definecolor{weirdbgcolor}{HTML}{FCF4F0}
\pagecolor{weirdbgcolor}

% Make bold text appear in a particular colour
\definecolor{boldcolor}{HTML}{6E0002}
\let\realtextbf=\textbf
\renewcommand{\textbf}[1]{\textcolor{boldcolor}{\realtextbf{#1}}}

% Use underlines instead of emphasis (ugh)
\renewcommand{\emph}[1]{\underline{#1}}
\hypersetup{breaklinks=false}

% % Use fixed-width font by default
% \renewcommand*\familydefault{\ttdefault}

\title{A64L(3)}
\author{}
\date{}

\begin{document}
\maketitle

\begin{longtable}[c]{@{}lll@{}}
\toprule\addlinespace
A64L(3) & Linux Programmer's Manual & A64L(3)
\\\addlinespace
\bottomrule
\end{longtable}

\hyperdef{}{NAME}{\section{\hyperref[NAME]{NAME}}\label{NAME}}

a64l, l64a - convert between long and base-64

\hyperdef{}{SYNOPSIS}{\section{\hyperref[SYNOPSIS]{SYNOPSIS}}\label{SYNOPSIS}}

\textbf{\#include \textless{}stdlib.h\textgreater{}}

~

\textbf{long a64l(char *}\emph{str64}\textbf{);}

~

\textbf{char *l64a(long}\emph{value}\textbf{);}

~

Feature Test Macro Requirements for glibc (see
\textbf{feature\_test\_macros}(7)): \\

~

\textbf{a64l}(), \textbf{l64a}():

~

\_SVID\_SOURCE \textbar{}\textbar{} \_XOPEN\_SOURCE~\textgreater{}=~500
\textbar{}\textbar{} \_XOPEN\_SOURCE~\&\&~\_XOPEN\_SOURCE\_EXTENDED

\hyperdef{}{DESCRIPTION}{\section{\hyperref[DESCRIPTION]{DESCRIPTION}}\label{DESCRIPTION}}

These functions provide a conversion between 32-bit long integers and
little-endian base-64 ASCII strings (of length zero to six). If the
string used as argument for \textbf{a64l}() has length greater than six,
only the first six bytes are used. If the type \emph{long} has more than
32 bits, then \textbf{l64a}() uses only the low order 32 bits of
\emph{value}, and \textbf{a64l}() sign-extends its 32-bit result.

The 64 digits in the base-64 system are:

\begin{verbatim}

'.' represents a 0
'/' represents a 1
0-9 represent  2-11
A-Z represent 12-37
a-z represent 38-63
\end{verbatim}

So 123 = 59*64\^{}0 + 1*64\^{}1 = ``v/''.

\hyperdef{}{ATTRIBUTES}{\section{\hyperref[ATTRIBUTES]{ATTRIBUTES}}\label{ATTRIBUTES}}

\hyperdef{}{Multithreadingux5fux28seeux5fpthreadsux287ux29ux29}{\subsection{\hyperref[Multithreadingux5fux28seeux5fpthreadsux287ux29ux29]{Multithreading
(see
pthreads(7))}}\label{Multithreadingux5fux28seeux5fpthreadsux287ux29ux29}}

The \textbf{l64a}() function is not thread-safe.

The \textbf{a64l}() function is thread-safe.

\hyperdef{}{CONFORMINGux5fTO}{\section{\hyperref[CONFORMINGux5fTO]{CONFORMING
TO}}\label{CONFORMINGux5fTO}}

POSIX.1-2001.

\hyperdef{}{NOTES}{\section{\hyperref[NOTES]{NOTES}}\label{NOTES}}

The value returned by \textbf{l64a}() may be a pointer to a static
buffer, possibly overwritten by later calls.

The behavior of \textbf{l64a}() is undefined when \emph{value} is
negative. If \emph{value} is zero, it returns an empty string.

These functions are broken in glibc before 2.2.5 (puts most significant
digit first).

This is not the encoding used by \textbf{uuencode}(1).

\hyperdef{}{SEEux5fALSO}{\section{\hyperref[SEEux5fALSO]{SEE
ALSO}}\label{SEEux5fALSO}}

\textbf{uuencode}(1), \textbf{strtoul}(3)

\hyperdef{}{COLOPHON}{\section{\hyperref[COLOPHON]{COLOPHON}}\label{COLOPHON}}

This page is part of release 3.54 of the Linux \emph{man-pages} project.
A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.

\begin{longtable}[c]{@{}ll@{}}
\toprule\addlinespace
2013-06-21 &
\\\addlinespace
\bottomrule
\end{longtable}
\end{document}

编辑

由于没有答案完全符合要求,因此我对问题进行了更改。这种变化也给了我相同的结果,但方式不同。

主要是,我想将所有粗体文本与同一个单词的标题链接起来。
例如,在我得到的地方,\textbf{malloc}我想与\title{MALLOC(3)}和\textbf{a64l}建立链接\title{A64L(3)}。

现在,我制作了一个index包含标题词的文件。
文件索引

MALLOC(3)
A64L(3)  

或者

 MALLOC
 A64L

或者

 malloc
 a64l

我想使用index文件修改主文件比以前的方法更容易。
伪代码

while read word
do
l_word=${word,,}
echo $l_word
sed -e 's/\\title{$word\(3\)}/\\title{\\hypertarget{$word}{$word\(3\)}}/' -e 's/\\textbf{$l_word}/\\textbf{\\hyperlink{$word}{$l_word}}/' inputfile > output.tex
done < index

[这段代码有一些错误,我无法检测到]

awk text-processing
  • 2 个回答
  • 243 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