首页 > 系统相关 >Linux tr command All In One

Linux tr command All In One

时间:2023-04-26 14:57:34浏览次数:34  
标签:files cs193p tr sites command https Linux pdf

Linux tr command All In One

tr 转义或删除字符

image

tr

$ man tr > man-tr.md

$ cat man-tr.md
TR(1)                                             User Commands                                            TR(1)

NAME
       tr - translate or delete characters

SYNOPSIS
       tr [OPTION]... SET1 [SET2]

DESCRIPTION
       Translate, squeeze, and/or delete characters from standard input, writing to standard output.

       -c, -C, --complement
              use the complement of SET1

       -d, --delete
              delete characters in SET1, do not translate

       -s, --squeeze-repeats
              replace  each  sequence  of  a repeated character that is listed in the last specified SET, with a
              single occurrence of that character

       -t, --truncate-set1
              first truncate SET1 to length of SET2

       --help display this help and exit

       --version
              output version information and exit

       SETs are specified as strings of characters.  Most represent themselves.  Interpreted sequences are:

       \NNN   character with octal value NNN (1 to 3 octal digits)

       \\     backslash

       \a     audible BEL

       \b     backspace

       \f     form feed

       \n     new line

       \r     return

       \t     horizontal tab

       \v     vertical tab

       CHAR1-CHAR2
              all characters from CHAR1 to CHAR2 in ascending order

       [CHAR*]
              in SET2, copies of CHAR until length of SET1

       [CHAR*REPEAT]
              REPEAT copies of CHAR, REPEAT octal if starting with 0

       [:alnum:]
              all letters and digits

       [:alpha:]
              all letters

       [:blank:]
              all horizontal whitespace

       [:cntrl:]
              all control characters

       [:digit:]
              all digits

       [:graph:]
              all printable characters, not including space

       [:lower:]
              all lower case letters

       [:print:]
              all printable characters, including space

       [:punct:]
              all punctuation characters

       [:space:]
              all horizontal or vertical whitespace

       [:upper:]
              all upper case letters

       [:xdigit:]
              all hexadecimal digits

       [=CHAR=]
              all characters which are equivalent to CHAR

       Translation occurs if -d is not given and both SET1 and SET2 appear.  -t may be used only when  translat‐
       ing.  SET2 is extended to length of SET1 by repeating its last character as necessary.  Excess characters
       of SET2 are ignored.  Only [:lower:] and [:upper:] are guaranteed to expand in ascending order;  used  in
       SET2  while  translating,  they  may  only be used in pairs to specify case conversion.  -s uses the last
       specified SET, and occurs after translation or deletion.

AUTHOR
       Written by Jim Meyering.

REPORTING BUGS
       GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
       Report any translation bugs to <https://translationproject.org/team/>

COPYRIGHT
       Copyright  ©  2020  Free  Software  Foundation,  Inc.   License  GPLv3+:  GNU  GPL  version  3  or  later
       <https://gnu.org/licenses/gpl.html>.
       This  is  free software: you are free to change and redistribute it.  There is NO WARRANTY, to the extent
       permitted by law.

SEE ALSO
       Full documentation <https://www.gnu.org/software/coreutils/tr>
       or available locally via: info '(coreutils) tr invocation'

GNU coreutils 8.32                               September 2020                                            TR(1)
pi@raspberrypi:~/Desktop/man-docs $ 

demos

pdf crawler / pdf 爬虫

#!/bin/bash 绝对路径 ⚠️

#!/usr/bin/env bash 相对路径 ✅

#!/usr/bin/env bash

# 下载目录
downdir="/Users/xgqfrms-mbp/Documents/swift-ui/Memorize/000-xyz/pdfs/"

# $1 是传递给 shell 的第一个参数
# read line 按行读取文件
cat $1 | while read line
do
  # shell 变量需要使用双引号包裹, 或 echo $line
  echo "$line"
  cd $downdir
  str=$line
  # 按行分割,每行一个, 正则表达式:字符串转数组
  array=(${str//;/ })
  echo "$array"
  url=${array[0]}
  # tr 删除换行字符 ✅
  filename=$(echo ${array[1]} | tr -d '\r')
  # filename=$(echo "l" + ${index} + ".pdf" | tr -d '\r')
  # filename=$(echo "l${index}.pdf" | tr -d '\r')
  # cURL 执行下载, -o 输出文件
  curl $url -o $filename
done

# exit 0

# mkdir pdfs
$ bash ./auto-download-pdfs.sh cs193p.txt
# OR, 可执行脚本
$ chmod +x ./auto-download-pdfs.sh
$ ./auto-download-pdfs.sh cs193p.txt

cs193p.txt

https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l1.pdf;l1.pdf
https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l2.pdf;l2.pdf
https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l3.pdf;l3.pdf
https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l4.pdf;l4.pdf
https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l5.pdf;l5.pdf
https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l6.pdf;l6.pdf
https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l7.pdf;l7.pdf
https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l8.pdf;l8.pdf
https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l9.pdf;l9.pdf
https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l10.pdf;l10.pdf
https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l11.pdf;l11.pdf
https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l12.pdf;l12.pdf
https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l13.pdf;l12.pdf
https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l14.pdf;l14.pdf

(

标签:files,cs193p,tr,sites,command,https,Linux,pdf
From: https://www.cnblogs.com/xgqfrms/p/17354482.html

相关文章

  • Android音频开发之AudioTrack
    原文地址www.jianshu.com在前两节中分享了Android音频开发之音频基本概念和Android音频开发之音频采集,本文分享的是如何使用AudioTrack来播放使用AudioRecord采集后的PCM数据。构造AudioTrack实例publicAudioTrack(intstreamType,intsampleRateInHz,intcha......
  • backtrader docker腳手架部署
    1.導讀兼容backtrader,pyfolio,zipline,yfinance的安裝版本saveBacktraderandPyfolioplotimage储存backtrader和pyfolio的图片 2.前言所謂一步一坑,當項目要自動化部署時,就要自己填坑了。 3.安裝流程3.1DockerfileFROMamd64/python:3.6ENVPYTHONUNBUF......
  • Linux扩大虚拟机系统磁盘空间
    Linux扩大虚拟机系统磁盘空间一、基本步骤1.虚拟机保持关闭状态,设置->磁盘->拓展->最大磁盘大小 设成30G2.创建新分区3.格式化分区4.挂载分区(创建新分区后,需要挂载才能使用)5.解挂分区(解挂后,数据会保留,重新挂载,数据依旧存在)6.删除分区(删除后,数据不存在) 二、创建......
  • .NET平台StringComparison类型的介绍
    简介C#中StringComparison的类型有以下几种:1.CurrentCulture:使用当前区域性敏感的比较规则进行比较。2.CurrentCultureIgnoreCase:使用当前区域性敏感的比较规则进行比较,但忽略大小写。3.InvariantCulture:使用固定的区域性敏感的比较规则进行比较。4.InvariantCultureIgnoreCa......
  • 快速上手Linux核心命令(六):Linux的文本编辑器vi和vim
    @目录前言简介小试牛刀vi/vim工作原理及三种模式常用快捷键命令行图解前言上一篇中已经预告,我们这篇主要说Linux中vi/vim编辑器。它是我们使用Linux系统不可缺少的工具,学会了,你就可以在Linux世界里畅通无阻,学废了,常用操作你也会了,也是够用了,O(∩_∩)O简介vi是Linux系统下标......
  • Struts2总结
    Struts2总结[code]一、Struts2概述Struts2其实并不是一个陌生的Web框架,Struts2是以Webwork的设计思想为核心,吸收了Struts1的优点,因此,可以认为Struts2是Struts1和Webwork结合的产物。一、MVC简介Struts2是一个兼容Struts1和WebWork的MVC框架,既然......
  • AtCoder Regular Contest 126 D Pure Straight
    洛谷传送门AtCoder传送门很不错的状压。考虑先把最后作为答案的数聚到一起,再算它们的逆序对个数。设\(f_S\)为当前选的数集合为\(S\)的答案。有转移:选\(a_i\),答案加上之前选的比它大的数;不选\(a_i\),此时需要把左边的数或者右边的数往中间挪一个,答案加上左右两端的最......
  • linux ssh互信配置
    linuxssh互信配置 环境:node1:192.168.3.20node2:192.168.3.21用到的命令ssh-keygen:创建公钥和密钥,会生成id_rsa和id_rsa.pub两个文件ssh-copy-id:把本地的公钥复制到远程主机的authorized_keys文件(不会覆盖文件,是追加到文件末尾),并且会设置远程主机用户目录的.ssh和.ssh/a......
  • rockyLinux 初体验(教程)PostgreSQL15
    目录数据库软件PostgreSQL安装数据库软件PostgreSQL配置数据库软件PostgreSQL交互通用数据库管理软件DBeaver彼时,PostgreSQL已经更新到了15.2。距离我上一次写PostgreSQL教程2022-03-20,已经过去一年多了。Linux篇PostgreSQL教程很久之前就想写了,一直停留在想法上......
  • Linux命令1_文件管理1
    一些符号~home目录/root目录.当前目录..上级目录......