AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / user-176227

alhelal's questions

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

O que posso fazer se o delimitador de csv aparecer no valor?

  • 0

Suponha que meu arquivo csv contenha

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

Eu quero carregar este arquivo de dados csv no banco de dados mysql usando o comando mysql como

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

Você também pode dizer para usar colocando cada valor "e usando enclosed by '"'a opção do mysql. Mas incluir cada valor é uma sobrecarga para mim.

Posso incluir apenas descriptionvalor se houver uma solução para ler esse tipo de csv em que uma coluna é incluída, "mas não todas.

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

Como fazer uma função no bash que insere um novo nome de arquivo entre outros?

  • 0

Suponha que eu tenha um diretório chamado Titlepageque tenha muitos arquivos chamados titlepage_1.pdf, titlepage_2.pdf... titlepage_n.pdfe seus texarquivos também. Eu tenho uma função bash que altera dois nomes de arquivo. (por exemplo $alterpdf 2 3, este comando troca o nome do arquivo titlepage_2.pdfpor titlepage_3.pdf. E faz a mesma coisa para os texarquivos correspondentes também.)

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; }  

Agora, quero uma função (por exemplo, filepush new.pdf 2 3) que possa inserir new.pdfdentro titlepage_2.pdfe titlepage_3.pdfcom o nome titlepage_3.pdf. E o número dos próximos arquivos é aumentado. titlepage_3.pdfpara titlepage_4.pdf titlepage_4.pdfpara titlepage_5.pdfe assim por diante.

Há também um .texarquivo para todos os pdf nesse diretório.

Editar
eu quero implementar segue-

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

Editar
solução proposta

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

Isso resulta no índice dos arquivos. Começando pela cauda, ​​incrementa cada índice adicionando 1 para cada arquivo até o ponto de inserção (2º argumento de push). Em seguida, renomeie o arquivo de destino ( new.pdf) paratitlepage_3rd_argement_of_push.pdf

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

Como chamar a função definida pelo usuário de outra função definida pelo usuário no bash?

  • -2

Eu quero fazer isso --

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; }  

Minha swapfunção funciona bem. Agora, quero usar a swapfunção dentro da alterpdffunção. Mas, isso produz erro -

insira a descrição da imagem aqui

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

Como fazer um pdf de muitos pdfs onde o nome do arquivo também é mostrado em um pdf?

  • 0

Eu tenho um diretório chamado Titlepageonde os arquivos (mínimo 10 pdf) são titlepage_1.pdf, titlepage_2.pdf, titlepage_3.pdf... . Cada um é uma página pdf.

Este diretório também está hospedado no Github para que as pessoas possam baixar as páginas de título facilmente. O diretório Github também contém o arquivo LaTeX correspondente.

Eu quero fazer um pdf combinado usando estes onde cada página contém 4 pdfs. E cada página de título também tem seu nome original. Para que qualquer pessoa possa escolher um pdf comparando tudo em um pdf e depois baixar a página de título de que precisa.

[Eu acho que isso pode ser feito usando pdfuite. E se não for possível usar apenas pdfunitecombinando com LaTeX]

insira a descrição da imagem aqui

ou

insira a descrição da imagem aqui

Editar

insira a descrição da imagem aqui

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

Como pesquisar texto armazenado em uma variável?

  • 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

grepleva $keycomo nome de arquivo, mas quero que ele pesquise o texto armazenado na variável $text.

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

Existe alguma maneira de copiar o conteúdo do arquivo na área de transferência sem abrir o arquivo? [duplicado]

  • 2
Esta pergunta já tem respostas aqui :
Copie o conteúdo de um arquivo para a área de transferência sem exibir seu conteúdo (4 respostas)
Fechado há 4 anos .

Sempre estou usando o vim como meu editor de texto. Mas, quando quero copiar o conteúdo completo do arquivo na área de transferência para colar em outro local, abro o arquivo no gedit e pressiono CtrlAe depois CtrlC.

Abrir o arquivo no editor de texto e pressionar CtrlAe, em seguida, CtrlCé uma sobrecarga para mim. Porque tenho que abrir o arquivo no editor de texto, embora não edite o arquivo.

Portanto, se houver algum comando que possa copiar o conteúdo do arquivo na área de transferência, é melhor.
por exemplo
clip file.txt

Também existe a possibilidade de obter esse recurso no vim mapeando CtrlApara algum comando ou fazendo um clipcomando para copiar. Mas não sei como copiar o arquivo inteiro no vim usando o comando.

NB Meu vim não suporta arquivos +clipboard.

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

Como imprimir alterações inline no sed?

  • -1

eu corro

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

Como posso visualizar as mudanças que sedestá fazendo em tempo de execução?

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

É possível adicionar algum texto no início de um arquivo na CLI sem criar um novo arquivo?

  • 1

Eu tenho dois arquivos; file1contendo -

hello world
hello bangladesh  

e file2contendo -

 Dhaka in Bangladesh
 Dhaka is capital of Bangladesh  

Eu quero atualizar file2como -

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

Isso é feito por -

cat file1 file2 >> file3
mv file3 file2  

Mas não quero criar um novo arquivo. Eu acho que usá sed-lo pode ser possível.

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

Como adicionar uma linha extra que também possui um padrão em arquivo contendo um padrão na linha anterior?

  • 1

Eu tenho um arquivo -

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

A palavra in {}pode ser qualquer coisa, mas a mesma em consecutiva {}.
eu quero pegar

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

Tentei seguir, mas falhei.

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

Esta é uma extensão de https://tex.stackexchange.com/questions/408244/how-to-make-toc-without-having-any-section-parts-name

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

Substituindo uma string diferente por uma nova string diferente que segue um padrão

  • 2

Eu tenho

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

Eu quero

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

ou

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

Estes são arquivos de amostra. Pode haver qualquer coisa em vez de A64Le MALLOC, mas siga o padrão (por exemplo \title{new_word}).

Eu tenho que fazer isso para obter os recursos descritos https://tex.stackexchange.com/questions/407884/how-to-make-a-title-as-link-target
Eu prefiro vim, sed, awk.

Sua resposta deve funcionar para seguir também-

\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}

EDITAR

Como nenhuma resposta se encaixa perfeitamente para o requisito, fiz uma alteração na minha pergunta. A mudança também me dá o mesmo resultado, mas de maneira diferente.

Principalmente, quero vincular todo o texto em negrito ao título da mesma palavra.
por exemplo Onde eu chegar \textbf{malloc}eu quero fazer um link com \title{MALLOC(3)}e \textbf{a64l}para \title{A64L(3)}.

Agora, crio um arquivo indexque contém a palavra do título. índice de
arquivo

MALLOC(3)
A64L(3)  

ou

 MALLOC
 A64L

ou

 malloc
 a64l

Acho que usar o indexarquivo modificando o arquivo principal é mais fácil do que o modo anterior.
pseudo-código

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

[Existem alguns erros neste código, que não podem ser detectados por mim]

awk text-processing
  • 2 respostas
  • 243 Views

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Possível firmware ausente /lib/firmware/i915/* para o módulo i915

    • 3 respostas
  • Marko Smith

    Falha ao buscar o repositório de backports jessie

    • 4 respostas
  • Marko Smith

    Como exportar uma chave privada GPG e uma chave pública para um arquivo

    • 4 respostas
  • Marko Smith

    Como podemos executar um comando armazenado em uma variável?

    • 5 respostas
  • Marko Smith

    Como configurar o systemd-resolved e o systemd-networkd para usar o servidor DNS local para resolver domínios locais e o servidor DNS remoto para domínios remotos?

    • 3 respostas
  • Marko Smith

    apt-get update error no Kali Linux após a atualização do dist [duplicado]

    • 2 respostas
  • Marko Smith

    Como ver as últimas linhas x do log de serviço systemctl

    • 5 respostas
  • Marko Smith

    Nano - pule para o final do arquivo

    • 8 respostas
  • Marko Smith

    erro grub: você precisa carregar o kernel primeiro

    • 4 respostas
  • Marko Smith

    Como baixar o pacote não instalá-lo com o comando apt-get?

    • 7 respostas
  • Martin Hope
    user12345 Falha ao buscar o repositório de backports jessie 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl Por que a maioria dos exemplos do systemd contém WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky Como exportar uma chave privada GPG e uma chave pública para um arquivo 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll status systemctl mostra: "Estado: degradado" 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim Como podemos executar um comando armazenado em uma variável? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S Por que /dev/null é um arquivo? Por que sua função não é implementada como um programa simples? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 Como ver as últimas linhas x do log de serviço systemctl 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - pule para o final do arquivo 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla Por que verdadeiro e falso são tão grandes? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis Substitua a string em um arquivo de texto enorme (70 GB), uma linha 2017-12-30 06:58:33 +0800 CST

Hot tag

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve